Shop OBEX P1 Docs P2 Docs Learn Events
Inverting Outputs — Parallax Forums

Inverting Outputs

Gary D.Gary D. Posts: 37
edited 2005-07-31 14:12 in BASIC Stamp
Ok simple question....
Given the following with a BS2

code var byte

code = 8

OUTH = code


the output of pins 8 through 15 would read

00001000

Is there a way in pbasic to invert this output?

code = 8

OUTH = code

11110111··· is the output i need.

or will i have to use·an inverter.

Thanks for all response...











▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
There are 10 kinds of people....

Those who know binary and those who Don't.

Comments

  • terrymrterrymr Posts: 19
    edited 2005-07-29 18:25
    OUTH = 255 - code
  • Paul BakerPaul Baker Posts: 6,351
    edited 2005-07-29 18:31
    That works, so does "OUTH = ~ code" (which also runs faster than subtracting)

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·1+1=10
  • Gary D.Gary D. Posts: 37
    edited 2005-07-29 18:46
    Haha I see...

    Basically what i am trying to do is start at 11111111 and finally get down to 00000000

    so therefore (without the loops)

    code = 255

    code = code - 1

    OUTH = code

    I new there was a simple way... Thanks Guys for letting me see the light

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    There are 10 kinds of people....

    Those who know binary and those who Don't.
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-07-29 19:02
    Why not just count backwards? -- PBASIC allows it:

    · FOR OUTH = 255 TO 0
    ··· PAUSE 1000
    · NEXT

    Remember that OUTH is a variable just like any other, except that it connects its bits to the outside world (P8..P15 in this case).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • Gary D.Gary D. Posts: 37
    edited 2005-07-29 19:12
    Great Jon, Even Easier....

    I didnt know that OUTH was a variable...

    Its kind of hard when my Help File is frozen... LOL.

    thanks Again.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    There are 10 kinds of people....

    Those who know binary and those who Don't.
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-07-29 19:26
    You really ought to read through our "What's A Microcontroller?" book -- it will be a few hours very well spent.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2005-07-29 19:34
    Sierra Wireless -

    That happened to me so many times with my Windows 98SE system, that I gave up trying to use the Help File from within the Stamp Editor. I just keep a shortcut to PBASIC.CFM right next to the Stamp Editor icon, and invoke it outside the Stamp Editor. It hasn't failed once since then.

    I suspect it has to do with running a low memory resource machine as I do, but I may be mistaken in that assessment. It's never failed (from within the Stamp Editor) with my Windows XP machine, which has 3 X the main memory (by necessity <sigh>) as my Windows 98SE machine. Often even the Stamp Editor will crash on my Windows 98SE machne, if I have more than two copies of Windows Internet Explorer active at one time (even though they're minimized). Admittedly, there are other things running concurrently as well. None of the other program or applications I run are so affected, however.

    Regards,

    Bruce Bates
  • Gary D.Gary D. Posts: 37
    edited 2005-07-29 19:39
    Jon,

    Its been a while since i have read That book...

    I like to skip a lot of stuff... i would really like to get into servo control... thats the only thing that baffles me...

    Pulse width modulation is a kicker...

    i have had two of my designs go to the patent office both of them utilizing One or more BS2 processors....

    Yet when i was earning my BSEE i wish i could have had your job... you truly have the job everyone wants... What a better way

    to make a living than to play with Parallax products all day. i have spoken to you over the years before i doubt you remember

    me at all. I am just another Vastly growing BS2 Hobbiest since 1998.

    Thanks always for your Help Jon.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    There are 10 kinds of people....

    Those who know binary and those who Don't.
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-07-29 22:28
    The great thing about WAM (hint, hint ... read it again) is that it will help you get into servo control. While I would hardly describe my job as "playing with Parallax products all day" it a pleasant way to put a roof over my head, and dare I say that a bad day at Parallax is better than a good day in most other jobs.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • allanlane5allanlane5 Posts: 3,815
    edited 2005-07-30 21:03
    Servo control is really simple. Servo's were made for model airplane control. They have inside them a small electric motor, a driver for that motor, a set of gears to move an output shaft through 180 degrees, and a variable resistor attached to those gears. It has a circuit attached to the variable resistor, that generates a pulse whose width depends on the position of the variable resistor, and thus the output shaft. It also has a comparator, that takes the control signal, compares it with the position of the variable resistor, and drives the motor so the shaft moves so the variable resistor changes position until it matches the input pulse width.

    Now, to control this, all you have to do is use the PULSOUT command to send the pulse-width signal, and repeat that every 20 mS to 50 mS. A 1.0 mS pulse will move far left, a 2.0 mS pulse will move far right, and a 1.5 mSec pulse will center the servo.

    Now, it is possible to "modify the servo", and disconnect the variable resistor from the gear train. You set the variable resistor to the center of its motion, and clip any limits from the gears so they can rotate continuously. Now your 1.0 mSec makes the servo rotate continuously one way, 2.0 mSec the other, and 1.5 mSec makes it stop. But you lose the 'absolute' positioning capability when you 'modify' a servo this way.
  • Gary D.Gary D. Posts: 37
    edited 2005-07-31 14:12
    Excellent... i have plenty of servos to play with both continuous rotation and absolute positioning.

    Thanks Very much for the info Allan, i cant wait to start.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    There are 10 kinds of people....

    Those who know binary and those who Don't.
Sign In or Register to comment.