Shop OBEX P1 Docs P2 Docs Learn Events
Mimicing a pulse — Parallax Forums

Mimicing a pulse

krazyideaskrazyideas Posts: 119
edited 2007-12-25 20:31 in BASIC Stamp
Ok so I have a eletric motor that I am trying to run off the computer.
I have a pulse in that tells me how fast each degree of the motor goes by.·
So·what I need to do is re-creat that pulse in but have it pulse 360 times.(hopefuly the positive and negative of the pulse are the same·time intervol) ·and then read the pulse in again and modifi it's self.

Right now what I am doing is

DO
· PULSIN pulse, 1, intime
···· intime = intime / 18········· (the pulse is divided by 18 because I'm getting the pulse from an 18 degree
···· DO··································window, and I need to know where each degree is)
····· PULSOUT 14, intime
····· reps = reps + 1
····· IF reps = THEN
····· IF reps = THEN
····· IF reps = THEN
····· IF reps = THEN
····· IF reps = THEN
····· IF reps = THEN
····· IF reps = THEN
····· IF reps = THEN
····· IF reps = THEN
····· IF reps = THEN
····· IF reps = THEN
····· IF reps = THEN
···· LOOP UNTIL (reps =· 360)

I think that will work but some thoughts on that would be great

I also have to know when each pulse goes off so that I can tell the coils when to turn on and off. Hence the counter called reps.· But before I go to the work of entering all the rest of the comands I wanted to have a better idea if it has a chance at working.

Thanks and MerryChristmas

Comments

  • phil kennyphil kenny Posts: 233
    edited 2007-12-24 15:06
    Whether it works as you want it to depends on the Stamp you're using
    and the maximum length of the input pulse you're measuring.

    At best, you'll only be able to measure every other pulse. Depending on
    how long the DO LOOP takes to execute, you might miss more than one
    pulse in.

    For a BS2 Stamp, the maximum length of a PULSIN measurement is about
    130 milliseconds. For the other Stamps, BS2x, BS2p, etc. the maximum
    length is about 52 milliseconds.

    What this means is that if your motor is moving too slowly, the PULSIN
    measurements won't be valid. Using a BS2, this translates to about 24 RPM.
    For the other Stamps the lower speed limit is about 58 RPM.

    The motor has to be moving faster than these speeds for the code to
    work properly.

    Another thing to consider is the delay in actually generating your output pulse.

    What are you you trying to do for each rep count? How long will this action
    take before your code goes through the DO LOOP again?

    phil

    Post Edited (phil kenny) : 12/24/2007 3:28:33 PM GMT
  • krazyideaskrazyideas Posts: 119
    edited 2007-12-25 15:20
    Hi Phil and Thanks

    K well I relise that the motor will have to be turning. But I didn't think about how long it would take the stamp to do all the commands.
    What I am trying to do with the pulsein is give my self a mapping point. If I know how long it takes for the motor to turn one degree, then I know where all and each of the 360 degrees of the motor lay. So from that I was planning on useing Pulseout to count off those 360 degrees and useing my rep counter to tell my coils when to turn on and off. I would have the do loop exicute 360 times before It would measue the pulsein again. SO the pulse in is mesured once per rotation but the pulse out pulses 360 times in a rotation.
    If I could know for sure the off time of each pulse I could put that in the timeing and the pulseout would only have to pulse 180 times in a rotation.
    All I'm really trying to do is make an acrruate map of the motors degrees and then having the ability to turn 6 coils on and off depending on where the motor lays in it's rotaion or the map. I can do it mechanicaly that's easy but I need to do it with the computer.
    Thanks Phil

    Crazyideas
  • phil kennyphil kenny Posts: 233
    edited 2007-12-25 16:14
    Merry Xmas,

    Even though you only want to make one PULSIN measurement
    per revolution of the motor, the DO LOOP will have to be
    executed 360 times during that one revolution of the motor.

    If you are using a BS2 Stamp, the widest pulse that PULSIN
    can measure is about 130 milliseconds. Dividing 130 by 360
    you get roughly 300 microseconds. That means that each pass
    the DO LOOP can't take more than 300 microseconds if you
    want the LOOP to execute once per degree of motor rotation.

    My earlier comment about minimum motor speed still holds.
    About 24 RPM if you are using a BS2.

    For faster motor speeds, you have less than 300 microseconds
    to get thru the LOOP.

    One way to speed up the code would be to use the LOOKDOWN
    instruction instead of 360 IF THEN statements. You will have
    to use two separate LOOKDOWN statements since each one can
    only handle 254 entries.

    In any event, the timing of code execution is the primary factor
    that will determine whether your concept is feasible.

    When it comes to time critical tasks, such as motors, it may be
    better to consider using another processor such as the Propeller.
    They can execute code MUCH faster.

    phil

    Post Edited (phil kenny) : 12/25/2007 4:19:43 PM GMT
  • krazyideaskrazyideas Posts: 119
    edited 2007-12-25 20:31
    Thanks Phil
    I'll do some digging and look up that comand and also look into the propeller processor
    Thanks Tons
    Crazyideas

    Merry Christmas
Sign In or Register to comment.