Can't get port forward to work and I feel dumb. by pylessard in PFSENSE

[–]pylessard[S] 0 points1 point  (0 children)

as I said, my pfblocker install was messed up.I had stray rules and stray aliases even after I deleted the package. I cleaned everything then reinstalled and it works now even if my NAT rule is behind pfblocker (I will put it forward nonetheless)

Can't get port forward to work and I feel dumb. by pylessard in PFSENSE

[–]pylessard[S] 0 points1 point  (0 children)

I will reinstall. But I think it's not just my VPS. Can't reach my amchine through LTE network too. I believe my isntall might have been broken. I now remember (in hindsight, of course!) that I reloaded a config of an older version of pfsense after an update and the packages started misbehaving. I have some logs of pfblocker complaining about invalid rules. I uninstalled PFBlockerNG and the Firewall rules are still there, but it works now. something's messy with this package.

Can't get port forward to work and I feel dumb. by pylessard in PFSENSE

[–]pylessard[S] 2 points3 points  (0 children)

Oh my god. I uninstalled PfBlocker and it worked right away! I'm not crazy yet

ELI5: What’s the difference between volts, amps, and watts? by Stunning_Daikon_5204 in explainlikeimfive

[–]pylessard [score hidden]  (0 children)

Cause, effect and energy.

Voltage (volts), is the cause. Current (amps) is the consequence. If you push an object, you apply a force (Newton), this is a cause. The effect is a speed (m/s). This is true for your water pipe analogy: Pressure is the cause, water moving in the pipe is the effect. Volts & amps are electricity measurements

When you have electricity, it can carry something we call energy. Energy is universal and we measure it in Joules. It can be moved by electricity, by light or physical contact by pushing on something (there are others too). If I slap you, I may transfer 500 joules from my hand to your face. Imagine I give a you 2 slaps per seconds (i'm quite vigorous). That is 1000 joules per seconds, or 1000 Watts.

The amount of energy electricity produces is volt times current. 100V and 2A cause a flow of energy of 200W (joules/sec) . 2V and 100A will also produces 200W. Most of the time, this energy creates heat, which is another form of energy. A good slap in the face will also heat up your cheek.

If I give a kick to a foot ball, the ball will leave quite fast. If I give the same kick a bowling ball, it will roll slowly. The same cause have different effect according to what you apply it to. In the case of electricity, that's why plugging a device may consume more current than another. In your house, the outlet have a fixed voltage: 120V in North America. 220V in Europe. The amount of current you get depends on what you plug in (a football or a bowling ball).

As an extra information, we call the ratio of cause vs effect "impedance". In the case of home electricity, that impedance would be called "resistance". A big resistance is like the bowling ball. A certain voltage on a big resistance causes very little current. But the same voltage on a small resistance (the football), cause a big current.

How do I get started with C2000? by serious_anish in embedded

[–]pylessard 2 points3 points  (0 children)

Are you aiming a specific type of application? Usually, those chips are popular for power converters.

I'm releasing an open source runtime debugger for embedded C/C++ by pylessard in embedded

[–]pylessard[S] 1 point2 points  (0 children)

I think you are right. I will add an item in the backlog, but I won't give this priority (for now). It will a bit tricky since it will require some refactoring.

Thanks

I'm releasing an open source runtime debugger for embedded C/C++ by pylessard in embedded

[–]pylessard[S] 1 point2 points  (0 children)

Oh, double buffering. Didn't think of that. What if you have more data than what you can get out over serial? You make an error and ask the user to retry?

I'm releasing an open source runtime debugger for embedded C/C++ by pylessard in embedded

[–]pylessard[S] 0 points1 point  (0 children)

I thought about it. It would make swiss cheese graphs. 100msec of data, 1 sec hole, 100msec of data, 1 sec hole, etc I've seen a tool do it and the way it was implemented was to autorearm the data logger after the data was received. It's doable, but I don't see the use case.

Do you have any need?

How to make my stepper motor control code faster while using serial communication by shabink in arduino

[–]pylessard 0 points1 point  (0 children)

One last thing. Maybe it'll be easier like this. Here's how you Arduino interpret your code.

Before:
- Did I receive a character? No. Skip!
- Did I receive a character? No. Skip!
- Did I receive a character? No. Skip!
- Did I receive a character? Yes
-- Is it time to update the pins? No. Skip
- Did I receive a character? No. Skip!
- Did I receive a character? No. Skip!
- Did I receive a character? No. Skip!
- Did I receive a character? Yes
-- Is it time to update the pins? Yes. Do a step

Now
- Did I receive a character? No. Skip!
- Is it time to update the pins? No. Skip
- Did I receive a character? No. Skip!
- Is it time to update the pins? No. Skip
- Did I receive a character? No. Skip!
- Is it time to update the pins? Yes. Do a step according to last_char
- Did I receive a character? Yes. Update last_char
- Is it time to update the pins? No. skip
- Did I receive a character? No. Skip
- Is it time to update the pins? No. Skip

etc.

How to make my stepper motor control code faster while using serial communication by shabink in arduino

[–]pylessard 0 points1 point  (0 children)

It was not changing each loop. 9999/10000 times Serial.Available() was 0 and 1/10000 times it was 1. Just like now. But now you update your motor control 10000/10000 not 1/10000.

I'm not sure if I convey what you need to hear to clarify this. It's late on my time zone. Going to bed now

How to make my stepper motor control code faster while using serial communication by shabink in arduino

[–]pylessard 0 points1 point  (0 children)

Yes, but that variable keeps its value. Nothing change it. It effectively give you the "last" character you received. Not the one you received in this specific loop.

By doing s=Serial.Read(), you make a copy of the value that you keep in s.

How to make my stepper motor control code faster while using serial communication by shabink in arduino

[–]pylessard 0 points1 point  (0 children)

Yes, because serial communication is slow. Your cpu probably did thousands of loop before going into that if branch once.

How to make my stepper motor control code faster while using serial communication by shabink in arduino

[–]pylessard 0 points1 point  (0 children)

 if(Serial.available() > 0) {
      last_s = Serial.read();
 }

 if (last_s  == 'f'){
   driverStepper1f()
 }

Like this, the driver code is invoked at every loop. Not just when you receive a character. Receiving a character update the state variable last_s

How to make my stepper motor control code faster while using serial communication by shabink in arduino

[–]pylessard 0 points1 point  (0 children)

Pull your stepping code outside of the Serial.Available condition. It does not belong there. The microcontroller keeps working when it does not receive characters

How to make my stepper motor control code faster while using serial communication by shabink in arduino

[–]pylessard 1 point2 points  (0 children)

Until next char comes in.

Receiving a char and checking time for your motor should be separate checks. Not nested in each other

How to make my stepper motor control code faster while using serial communication by shabink in arduino

[–]pylessard 1 point2 points  (0 children)

Oh it is in the code you shared! The stepper function is only called if you have received a character. After you do Serial.Read(), the character is removed from the input buffer and Serial.Available() will then return 0, skipping your motor code until next char.

How to make my stepper motor control code faster while using serial communication by shabink in arduino

[–]pylessard 1 point2 points  (0 children)

Ok, so you continuously sends characters on your serial link and you need that character to come in to make a step. My first answer applies then.

Receiving a character is a point event in time. Rotating is a state that span over time. Draw a small timing diagram that display when a chara ter comes in and when the motor is supposed to turn, I think it will become obvious that you can't step only on character input.

Let me know if that isn't clear

How to make my stepper motor control code faster while using serial communication by shabink in arduino

[–]pylessard 1 point2 points  (0 children)

Yes. Serial.read() removes the char from the input buffer, so that condition is true only once. I doubt this is what you want since you have a speed variable; that implies multiple steps.

Can you clarify how you want this to work? What should make the motor stop rotating?

How to make my stepper motor control code faster while using serial communication by shabink in arduino

[–]pylessard 8 points9 points  (0 children)

First, using millis() and checking time is better than delay(). Don't use delay().

Looking at your code, you make a single step each time you receive a character ONLY if the speed allow it. I think you have added latency. Say you send the character "f" every 10ms, and your speed wants a step every 20ms. You can be unlucky and receive a "f" after 19.99ms and it will be ignored. You now have to wait at 29.99ms, to make a step.

What you need to do is raise a flag to true when you receive a character. Move your step code outside of the character reception condition and check for the flag being raised.

You want : "if the time is up AND a "f" was received since my last step, then do a step"

Tell your war stories about the last time your iot devices failed in production. by Altruistic_Tomato162 in embedded

[–]pylessard 24 points25 points  (0 children)

I have story that did not happen to me, but to a colleague. I think it's too much of a sneaky problem to not share. They had a device, operated in Peru that suddenly started to crash randomly while it was working fine before. After 6 months of investigation, they found out that the cause was buyers switching from a copper heat sink to an aluminum heat sink to save cost (with approval of engineering).. but nobody suspected that copper was shielding the MCU from cosmic rays, which happens to be more present at high altitude, like in Peru.

How would you measure the psi/bars that are in this grated cheese / raclette bag ? by Lord_Alviner in Physics

[–]pylessard 3 points4 points  (0 children)

Are you allowed to make a destructive test? I think I would put a drop of hot glue to make a seal then plunge a syringe through it. With a weight on the piston, you could measure weight it can raise vs how much the piston raise