Intro and advice on LED bar graph RPM meter
hoff70
Posts: 7
Hi,
I've always been interested in tinkering with electronics and have been fooling with some projects off and on for a couple of years. Mainly just repairing stuff by soldering in new components and a little breadboarding. I find it very rewarding even with my limited experience! Anyway, I decided to devote some space into a little "lab" for keeping my growing pile of stuff and tinkering around.
I recently picked up an Arduino UNO and a Prop and it's been fun tinkering with them but my computer code chops = ZERO! I've been bouncing between the UNO and Prop and I haven't really settled on a platform yet. I suppose I need to stick with one at least until I get some basics down...
This is my latest project:
Probably pretty simple for most folks here but I'm a bit flummoxed.
The breadboards and associated crapola is just a test platform that spins a disc which breaks an IR beam, plus a rig to vary the motor RPM. The trigger is running to an input on the UNO which prints 1 or 0 to the serial monitor and blinks an LED when the beam is broken. I figured it was a good/simple place to start.
The LED setup is (Hopefully) going to be a simple tachometer with the LED's lighting up from green to red as the RPM increases.
Any help would be greatly appreciated! Maybe it's overkill using a Prop for such a simple task but I also have some more tasks for it if I can get this working. I realize that each LED will require it's own pin, plus some resistors or voltage regulation, etc. and I understand the logic behind what I'm trying to do but I don't know how to tell the machine what to do.
I have a trial version of 12 blocks which looks like an IDEAL solution to some of my problems but documentation is lacking.
Thanks in advance!
Oh yea, I plan on using a hall effect sensor for the final product but they are on order. I got the IR setup from RS because I figured the input would be about the same. I would like to have it mostly worked out by the time they arrive.
I've always been interested in tinkering with electronics and have been fooling with some projects off and on for a couple of years. Mainly just repairing stuff by soldering in new components and a little breadboarding. I find it very rewarding even with my limited experience! Anyway, I decided to devote some space into a little "lab" for keeping my growing pile of stuff and tinkering around.
I recently picked up an Arduino UNO and a Prop and it's been fun tinkering with them but my computer code chops = ZERO! I've been bouncing between the UNO and Prop and I haven't really settled on a platform yet. I suppose I need to stick with one at least until I get some basics down...
This is my latest project:
Probably pretty simple for most folks here but I'm a bit flummoxed.
The breadboards and associated crapola is just a test platform that spins a disc which breaks an IR beam, plus a rig to vary the motor RPM. The trigger is running to an input on the UNO which prints 1 or 0 to the serial monitor and blinks an LED when the beam is broken. I figured it was a good/simple place to start.
The LED setup is (Hopefully) going to be a simple tachometer with the LED's lighting up from green to red as the RPM increases.
Any help would be greatly appreciated! Maybe it's overkill using a Prop for such a simple task but I also have some more tasks for it if I can get this working. I realize that each LED will require it's own pin, plus some resistors or voltage regulation, etc. and I understand the logic behind what I'm trying to do but I don't know how to tell the machine what to do.
I have a trial version of 12 blocks which looks like an IDEAL solution to some of my problems but documentation is lacking.
Thanks in advance!
Oh yea, I plan on using a hall effect sensor for the final product but they are on order. I got the IR setup from RS because I figured the input would be about the same. I would like to have it mostly worked out by the time they arrive.
Comments
First off, if you have any code for the prop, best way to get a hand is to share how far you are to this point. It goes a long way in getting some advice.
The way I would tackle something like this is using one of the fine PWM objects in the Obex, and get to the point where you are storing your RPM as a variable. I have had good luck with Dave Fletcher's Frequency meter in measuring the PWM signals from computer fans.
Lighting the "bargraph" LED's can be as simple as:
Of course you would have to add in a way to shut the LED's off when the RPM drops below a certain level... and of course there are many (and obviously better) ways of doing this with less lines of code, but this should give you the basic idea, and introduce a few concepts to you like using constants to make your life easier in calibrating your device, etc.
Good luck, and have some fun!
Here's where I'm at now:
Since I have a quickstart I'm running pins 1,3,5,7, etc. It appears as if I'd be better off getting the led's on sequential pins as suggested.
I'm pretty stoked about putting some fire to this thing!
Robert
Note: This line of code only sets P8 to output mode. You need to modify it to this:
So long as you're using contiguous pins you can simplify your code with this method -- it takes the MSB and LSB pin numbers, as well as the number of elements lit.
Edit: hoff70 you could also use outa or dira[0..8]~ to clear all bits or dira[0..8]~~ to set all bits
I did get this far today:
It's really crude though. Just turning pins off/on with some delay but it does help me see what's going on. I didn't anticipate the delay causing the blinking action (duh...) But at least I have some hardware set up to fool with.
My goal is to get some input from the IR setup over the weekend and get the LED's to do something. My IR setup is a bit hit or miss with some off or on doubling.
The serial port will occasionally throw a 101010001 or 101010111... I'm going to fool with the slotted disc some more to try smoothing things out. Maybe it's not "fast" enough? It works well on slow speeds but gets wonky when I turn up the RPM.
Hopefully the HE sensor will be a better trigger but it could be another can-O-worms!
I do have the LED's set up on 0-9 so that should simplify things.
Yea, I need to clean the bench!
It's an Arduino running a PWM program so I can vary the motor speed. I also tried to do a better job "shielding" the IR emitter by using a metal disc. (Had to finish a jar of olives, and that required a bottle of wine... The price we pay...)
Anyway, I managed to get the signal from the IR detector to the Prop by using the "Count edges" block. Now it registers on the "Pin states" screen each time the beam shines through the hole. I actually consider this a breakthrough! Pun intended...
I've been fooling with it about all day. I'm leaning towards the "Count edges" block in 12 Blocks because it can be set to count over a value. 60000 = 1 minute so that would give me my RPM. I think...but I'm a bit stumped now.
I still haven't managed to get the input over to any kind of output but I'm working on it. Thanks for the code examples! I'm beginning to get some fuzzy ideas about what's going on.
I think i may benefit from either a pull-up, or pull-down, resistor on the pin that's reading. Any input?
I've been fooling with the code posted but still no huzzah.
well, I met my goal for the weekend! The LED's don't reflect RPM other than blinking slower/faster with the disc speed but it's a start
I actually did this fumbling around with 12 Blocks..
I am Jhone from USA .I am new here with name as jaleb. I love to work with LED lighting. You have shared a good information, i am here to find out the solutions of problems face day by day. I hope you guys will help me out.
Welcome to the forums. You will get lots of help with your questions here. Just try to post as much information (along with code and schematics if possible) along with the questions.