GPIO processing speed

HI,

Im trying to count the amount of signals of a stamping machine. Every 200miliseconds there is a signal. Is this possible to count within node-red and a Raspberry PI 3b+? or is the processing time to count a signal more then 200 miliseconds?

Sounds well within the capabilities of a Pi and Node-RED

Any recommendation how to count it?

That's a very open ended question. Are you looking for a daily count? An hourly count? A total lifetime count? A rolling average? Different use cases will require slightly, or possibly even very different approaches.

A daily count would be the best if possible

The node-red-contrib-counter would be the place to start

image

If there is a signal every 200 milliseconds then the signal count per day is 432000, or do the signals themselves contain more information?

Or are you trying to count how long the machine is working per day?

While 200 mS should be fine - for something that is happening like that all day I would probably use something more dedicated like an arduino or esp8266 chip to be a dedicated counter - then feed the result to Node-RED. That way you won't miss anything if you have to restart the Pi for whatever reason - like upgrade, re-deploy, etc

2 Likes

It is the amount of products the machine makes. Every 200ms +/- there is a product

Well, i understand it. But it's only for 1 shift, so 8 hours a day. Any updates or upgrades i can do before or after that time.

About the esp8266 or esp32. Could i use Mqtt to communicate? It's just a signal 1 or 0.

I tried the counter node but when the manual counter on the machine counts 50 the counter node counts 3? And when i look into the raspberry pi pin node it flashes (1,0) way to slow like every second it changes. Or could this be a framerate issue?

I don't think its a framerate issue - I can count pulses every 200ms very reliably
image

Do you know the specification of the pulse width coming out of the machine?

Try adjusting the Debounce time parameter to a value of 1 ms and see if reliability improves
image

Hi,
As mentioned in this thread... you could use the ESP8266 to count the pulses.
The Wemos D1 Mini (running ESP Easy firmware) is a great board/module and very inexpensive.
It has loads of plugins including a 'count' facility and MQTT (so you could send the 'count' value to Node-RED via MQTT).

I prefer to use an inexpensive board for sensing switches and transducers rather than using the RPi's GPIO pins because if you have a problem (with wiring or voltage levels) you have only destroyed a 'cheap' unit rather than an expensive Raspberry Pi.

2 Likes

Im trying it now. Im not sure of the pulse width but i can see that with 1mS it's a bit optimistic and 50mS is no result (stays on 0). So it should be between those i think?

I understand your comment. The raspberry is galvanic isolated from the machine, so it should not be a problem.

What to you mean by a bit optimistic?

It was counting more then the machine. But i noticed it counts the signals 0 and 1 so it doubles it.

So does that mean that with 1ms it is working correctly, once you divide by 2?

Yeh, it works. Im gonne test if i can use mqtt to get them on my server. :crossed_fingers:

Even if you can get it to work, I'd still follow Dave's advice and use an ESP8266 to do the counting and then reduce the updates to MQTT to a more manageable level - every few minutes unless you really need it more often (what would you do with information moving that fast though?).

An ESP8266 is WiFi connected and there are MQTT libraries that allow you to write direct.

While a 200ms signal may process just fine most of the time, You cannot be sure that something happening on your Pi won't pause processing because Linux is not a real-time OS. The ESP8266 however IS a real-time system.