Good Evening All,
simpsonmichael1
Posts: 13
Good Evening All,
I need help with a DIY encoder system utilizing the bs2 micro-controller. Although, I saw kit encoders on the market, my robot is very large. My robot's rear wheels have a 6-inch diameter. I am using two scooter motors via chain drive. I have a simple light circuit using a flashlight and LDR connect the micro-controller. I'm using 2.5 PBASIC software to read in the input values, if true. However, when I try to code...it does not work well. See below.
desiredDX var word
count1 var word
Revcount1 var word
DO
Debug "Enter the distance desired", CR
DEBUGIN desiredDx
FOR count1 1 to 48
If (in3 = 1) then //sensor setup to provide a high on pin 3
count1 = count1 +1
Else
Debug "No input because no light on sensor", CR
Endif
Next
If (count1 > 47) then
RevCount1 = RevCount1 +1 //RevCount would be equal to a predetermined distance like if 100 this would be 20 feet. I
If (RevCount = 100) then
Stop
LOOP
However, even with no light the counter continues erratically or it counts when light is applied, but the RevCount always fails to work. I'm new to programing, so I need a bit of help. I am willing to learn. I find it difficult to do, but robotics is fun and rewarding.
I have read a few examples on counters, but want I really want to do is count the amount of times the spinning wheel (with holes in a CD disk) breaks the light path. If it breaks the light path x number of times, then I want to compare those values to a fixed distance. If the fixed distance is equal to my user desiredDX, then my robot will not move any further (in a straightline). If possible, does anyone know how to reuse an old computer mouse for an "encoder system" and how to write an example program for a bs2 micro-controller? Plead advise. Thank you.
Post Edited By Moderator (Joshua Donelson (Parallax)) : 10/23/2009 4:12:42 AM GMT
I need help with a DIY encoder system utilizing the bs2 micro-controller. Although, I saw kit encoders on the market, my robot is very large. My robot's rear wheels have a 6-inch diameter. I am using two scooter motors via chain drive. I have a simple light circuit using a flashlight and LDR connect the micro-controller. I'm using 2.5 PBASIC software to read in the input values, if true. However, when I try to code...it does not work well. See below.
desiredDX var word
count1 var word
Revcount1 var word
DO
Debug "Enter the distance desired", CR
DEBUGIN desiredDx
FOR count1 1 to 48
If (in3 = 1) then //sensor setup to provide a high on pin 3
count1 = count1 +1
Else
Debug "No input because no light on sensor", CR
Endif
Next
If (count1 > 47) then
RevCount1 = RevCount1 +1 //RevCount would be equal to a predetermined distance like if 100 this would be 20 feet. I
If (RevCount = 100) then
Stop
LOOP
However, even with no light the counter continues erratically or it counts when light is applied, but the RevCount always fails to work. I'm new to programing, so I need a bit of help. I am willing to learn. I find it difficult to do, but robotics is fun and rewarding.
I have read a few examples on counters, but want I really want to do is count the amount of times the spinning wheel (with holes in a CD disk) breaks the light path. If it breaks the light path x number of times, then I want to compare those values to a fixed distance. If the fixed distance is equal to my user desiredDX, then my robot will not move any further (in a straightline). If possible, does anyone know how to reuse an old computer mouse for an "encoder system" and how to write an example program for a bs2 micro-controller? Plead advise. Thank you.
Post Edited By Moderator (Joshua Donelson (Parallax)) : 10/23/2009 4:12:42 AM GMT
Comments
In the future please try to use a descriptive subject for your posts. "(No Subject)" doesn’t convey what you need help with. This will often limit potential useful responses as those who can help may never see your message.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
PS - Great way to recycle a CD coaster.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Engineering