I can't get BS2 to turn on and off in microsecond intervales
krazyideas
Posts: 119
I am makeing a eletric motor
I need to turn coils on and off in a vareating length of time dependeing on the speed of rotation of the motor
So what I have done is takein a 18 degree window mesured by lights. I then mesure the window with pulesin and call it x.· I then take x and times it by 20 making or giveing the time it will take for the motor to make 360 degrees, and then divide it by 360 giveing me the time it will take for the motor to turn 1 degree at any speed of rotation and I call it y.
I then tell the coils to turn on and off useing y * some number
My code looks like (this is the part of my code that is not working)
DO
pulsein pulse ect..
y = (x * 20) / 360
high 14
pause (y * 12)
high 13
pause (y * 2)
low 14
pause (y * 10)
low 13
LOOP
But the coils turn on and off very very slowly, they need to be turning on and off in microseconds
What I want to happen is every time the motor makes one rotation, the window to be mesured and the code updated through the use of my varubles.· Thus the coils will be turning on and off on time with a very small window of error, which is ok.
Now I do get the motor spinning well within the pulsein duration limits of the BS2 before I turn it on.
It then takes several·seconds for the coils to start turning on and off, I think that they should start the same time I turn the board on, should they not???
I am running the pulse through a votage reducer so as not to hurt my board of education, but that should not change the pulse window should it??
I know that I could make the timeing mechanical but I want to do it with the computer.
I can't even get the BS2 to turn on and then off in microseconds.· The book says you can but I can't
how· would you make it only turn on for a few microseconds????
So more or less HELP
this is my first project with a computer or the basic stamp
Thanks
I need to turn coils on and off in a vareating length of time dependeing on the speed of rotation of the motor
So what I have done is takein a 18 degree window mesured by lights. I then mesure the window with pulesin and call it x.· I then take x and times it by 20 making or giveing the time it will take for the motor to make 360 degrees, and then divide it by 360 giveing me the time it will take for the motor to turn 1 degree at any speed of rotation and I call it y.
I then tell the coils to turn on and off useing y * some number
My code looks like (this is the part of my code that is not working)
DO
pulsein pulse ect..
y = (x * 20) / 360
high 14
pause (y * 12)
high 13
pause (y * 2)
low 14
pause (y * 10)
low 13
LOOP
But the coils turn on and off very very slowly, they need to be turning on and off in microseconds
What I want to happen is every time the motor makes one rotation, the window to be mesured and the code updated through the use of my varubles.· Thus the coils will be turning on and off on time with a very small window of error, which is ok.
Now I do get the motor spinning well within the pulsein duration limits of the BS2 before I turn it on.
It then takes several·seconds for the coils to start turning on and off, I think that they should start the same time I turn the board on, should they not???
I am running the pulse through a votage reducer so as not to hurt my board of education, but that should not change the pulse window should it??
I know that I could make the timeing mechanical but I want to do it with the computer.
I can't even get the BS2 to turn on and then off in microseconds.· The book says you can but I can't
how· would you make it only turn on for a few microseconds????
So more or less HELP
this is my first project with a computer or the basic stamp
Thanks
Comments
The BS2 executes about 4000 instructions per second with a statement requiring from one to several
instructions. Something simple like LOW or HIGH would use one instruction while something like
SEROUT could use several. That's about 250us per "instruction". If you need higher speed, you
would need to use a processor like the SX or Propeller.
Your pauses are on the order of milliseconds and the pulses would be on the same order. If you are
not seeing the power get to the motor, you may have a problem with the drive circuitry between the
Stamp and the motor. You need to attach a schematic and your program to your reply otherwise it's
hard to give you more than general advice.
You must be careful with division on the BS. Dividing x with a number that has a remainder will result in the remainder being lost. The division results will not be exact.
PAUSE on the BS2 is in 1 millisecond per unit. PULSIN on the BS2 is in 2 microsecond per unit.
If the motor is rotating at lets say 6000 RPMs:
That would be 10 milliseconds per 360 degrees of motor shaft rotation.
y=would be 14 or 28 microseconds
high 14
pause (y*12) would be 168 milliseconds - about 17 complete 360 degree motor shaft rotations
high 13
pause (y*2) would be 28 milliseconds - about 3 complete 360 degree motor shaft rotations
low 14
pause (y*10) would be 140 milliseconds - about 14 complete 360 degree motor shaft rotations
low13
LOOP the loop would pause for 336 milliseconds - about 34 complete 360 degree motor shaft rotations
Hope this helps!
Post Edited (LilDi) : 11/21/2007 11:05:23 PM GMT