Shop OBEX P1 Docs P2 Docs Learn Events
USB to serial interface — Parallax Forums

USB to serial interface

epicjr77epicjr77 Posts: 29
edited 2008-04-25 16:09 in BASIC Stamp
Hello I have a USB to serial interface, and for some reason my robot on runs the program correctly if the serial is connected into the board of education. If I unplug it it freaks out for some reason. I Blew my first basic stamp 2, so I bought a new 1 off ebay and it is a rev G, any ideas whats going on?

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-04-25 03:36
    You'll have to be more specific about what's happening and how you have things connected up. You'll also need to attach your program to your reply. There's no fundamental reason why what you're describing shouldn't work, so there must be something about the details that's causing problems.
  • allanlane5allanlane5 Posts: 3,815
    edited 2008-04-25 13:14
    Sounds like a grounding problem. How are you powering your BOE?
  • epicjr77epicjr77 Posts: 29
    edited 2008-04-25 14:57
    I am powering it with a 9V dc power supply I bought from parallax, here is my program

    ' {$STAMP BS2}
    ' {$PBASIC 2.5}

    DEBUG "Program is running"

    '
    ( Variables)

    pulseCount VAR Byte 'For Next loop counter.


    '
    (initialization)

    FREQOUT 4, 2000, 3000 ' signal program start/ reset.

    '
    (main ROutine)

    DO

    IF ( IN5 = 1) AND ( IN7 = 1) THEN
    GOSUB Back_up 'Back up and U turn (left twice)
    GOSUB Turn_left
    GOSUB Turn_left

    ELSEIF (IN5 =1) THEN 'left switch hits
    GOSUB Back_up
    GOSUB Turn_right

    ELSEIF (IN7 = 1) THEN ' right switch hits
    GOSUB Back_up
    GOSUB Turn_left

    ELSE
    GOSUB Forward_pulse ' No hits send foward and check again
    ENDIF

    LOOP


    '
    (Subroutines)

    Forward_pulse:
    PULSOUT 13, 850
    PULSOUT 12, 650
    PAUSE 20
    RETURN

    Turn_left: ' about 90 degrees
    FOR pulsecount = 0 TO 20
    PULSOUT 13, 650
    PULSOUT 12, 650
    PAUSE 20
    NEXT
    RETURN

    Turn_right:
    FOR pulsecount = 0 TO 20
    PULSOUT 13, 850
    PULSOUT 12, 850

    PAUSE 20
    NEXT
    RETURN

    Back_up:
    FOR pulsecount= 0 TO 40
    PULSOUT 13, 650
    PULSOUT 12, 850
    PAUSE 20
    NEXT
    RETURN
  • Mike GreenMike Green Posts: 23,101
    edited 2008-04-25 15:05
    Again, there's nothing wrong with what you've posted so far, so your problem must be in something you haven't told us yet. "Freaks out" is not a useful term for figuring out what's wrong. Maybe some more detail would help.
  • epicjr77epicjr77 Posts: 29
    edited 2008-04-25 15:11
    When I say freak out I mean that the to motor servos act like I am hitting the switch ( the robot backs up and turns around) repetitively , however I am no where near the switch. When I plug in the serial cable the servos drive straight until I touch the switch.
  • MSDTechMSDTech Posts: 342
    edited 2008-04-25 15:23
    Are these switches the wiskers that come with the Boe-Bot? The first though that comes to mind is that removing the serial cable changes the center of gravity of the Boe-Bot. This may cause a slight forward motion of the unit that causes a loose connection to make/break contact. Make sure all of the components are tight.
  • Mike GreenMike Green Posts: 23,101
    edited 2008-04-25 15:26
    It sounds like electrical noise, probably from the servo motors, is getting into the switch circuits. You didn't say if you're using a BoeBot. If so, are you running the servos off Vin or Vdd? There's a jumper on the BOE to select the power source for the servos. If you select Vin, that will partially isolate the servos from the logic circuits, but you'll have to be careful to use a power source of no more than 7V. A 4 AA battery pack is ok as well as a 6V AC supply, but don't use more than a 7V AC supply or you will cause increased wear on the servos' motor brushes.

    There's something odd about your switch setup. In the BoeBot, the switches are wired to connect to ground when closed (logic zero) and there's a 10K pullup resistor to Vdd that provides a logic one when the switch is open. In your case, you're testing for a logic one for when the switch is closed. If you've got things reversed, make sure you have a pulldown resistor. Look in the "Robotics for the BoeBot" tutorial from Parallax's Stamps in Class downloads page for the schematics.
  • epicjr77epicjr77 Posts: 29
    edited 2008-04-25 15:27
    I just tried removing the switch completely and the servos still act like the switch was being activated, once again it works fine when the serial plug is connected to the board and computer
  • MSDTechMSDTech Posts: 342
    edited 2008-04-25 15:31
    Can you post a picture of the unit and switches?
  • epicjr77epicjr77 Posts: 29
    edited 2008-04-25 15:31
    I am not using boe bot, and I am running off of VIN, I will look at the boe bot thanks
  • Mike GreenMike Green Posts: 23,101
    edited 2008-04-25 15:39
    Again, it sounds like electrical noise coupling through to the switch circuitry. Without a circuit diagram, it would be difficult to give you anything other than general suggestions.
  • epicjr77epicjr77 Posts: 29
    edited 2008-04-25 15:45
    I dont have a way of showing it but basically it I/O 5 to a 220ohm to the switch to a 10k resistor to Vdd
  • allanlane5allanlane5 Posts: 3,815
    edited 2008-04-25 16:09
    And the other end of the switch goes to Vss, right? So when the switch is 'closed', you get a zero, but when the switch is 'open' you get a 1 (high).

    "Backs up and turns around" is what the 'bot does when both switches are open, in your current code. Is that what you intend?

    So, are you sure the 'other end' of the switch goes to a good "Vss"? You could measure this with a voltmeter.
Sign In or Register to comment.