Need help with code for Determining the speed of DC motors based on Hall sensors
Klaus Gawelczyk
Posts: 9
Need help with code for Determining the speed of DC motors (EMG30) based on Hall sensors - using Basic Stamp 2
Has anyone used the I2C to drive the MD25 (motor driver board) with EMG30 (Hall - encoder, motor, gearbox 30:1) see on http://www.robot-electronics.co.uk/htm/md25tech.htm
I use the program written by Chris Clarke - Aug 2008 (Parallax Board of Education and BS2p24 - I2C Bus is connected to P0 and P1) with my changes - it does very well.
I2C bus is working properly, the Hall sensors provide per gear shaft rotation (motor 1 and motor 2) 360 pulses (I can count the pulses continuously)
I'm looking for a way to determine the speed - this requires the number of pulses counted per minute (or second) RPM
speed = (3.1415) *( wheel diameter) * (number of revolutions RPN)
Has anyone written a source code, please help me write a code
Hi to all of you
Klaus Gawelczyk /Germany
Has anyone used the I2C to drive the MD25 (motor driver board) with EMG30 (Hall - encoder, motor, gearbox 30:1) see on http://www.robot-electronics.co.uk/htm/md25tech.htm
I use the program written by Chris Clarke - Aug 2008 (Parallax Board of Education and BS2p24 - I2C Bus is connected to P0 and P1) with my changes - it does very well.
I2C bus is working properly, the Hall sensors provide per gear shaft rotation (motor 1 and motor 2) 360 pulses (I can count the pulses continuously)
I'm looking for a way to determine the speed - this requires the number of pulses counted per minute (or second) RPM
speed = (3.1415) *( wheel diameter) * (number of revolutions RPN)
Has anyone written a source code, please help me write a code
Hi to all of you
Klaus Gawelczyk /Germany
Comments
Thanks for the reply
Can your proposal be used in I2C bus? - my PIN 0 and 1 are supported by I2C BUS ---> here an example of the frequency measurement without I2C bus (See source code and wiring http://www.parallax.com/dl/docs/books/sw/exp/sw17.pdf) Can the same PIN be used for the bus and for COUNT?
' {$STAMP BS2p}
' {$PBASIC 2.5}
FreqPin CON 0 ' frequency input pin
OneSec CON 3484 ' one second - BS2p
' OneSec CON 1000 ' BS2
' OneSec CON 2500 ' BS2sx
' OneSec CON 3484 ' BS2p
freq VAR Word ' frequency
Main:
COUNT FreqPin, OneSec, freq ' collect pulses for 1 second
DEBUG CLS, "Frequency: ", DEC freq, " Hz" ' display on DEBUG screen
GOTO Main ' do it again
END
Thank you for your support
Klaus Gawelczyk/Germany
You don't have to use pins 0 and 1 for an I2C bus. The only time the Stamp makes use of them that way is when your program actually executes an I2C statement. If you're not using the I2C statements, you can use those I/O pins for any other purpose.
I can make my application differently - default route via count Increments - I want to make a differential gear (steering over different wheel speeds - 2 DC gear motors at a pivot point)
Perhaps even help come up with an idea
I have just tried <<< COUNT >>> - it does not go together with the I2C bus
by
Klaus Gawelczyk / Germany)
Your idea is good but I can not stop the continuous pulse counting in the loop << for example .... do while (Impulse1 < 3600) .... >> (here it runs the odometry) - I'll think about something to how can time be stopped - interrupt? is that possible with BASIC Stamp?
by
Klaus Gawelczyk / Germany
What do you think about POLLIN with BS2P24 - do you have an example code? (I have no experience with POLLIN)
by
Klaus Gawelczyk /Germany
2) I don't recommend using the POLLxxx statements. They're not true interrupts. Specifically, they don't save state (location in the program, variables, etc.) They are sometimes useful, but difficult to use successfully.
3) Your motor controller already provides counters for the wheel encoders. Are you trying to duplicate this functionality? Why?