Shop OBEX P1 Docs P2 Docs Learn Events
Help With I/O Pins — Parallax Forums

Help With I/O Pins

firewirefahselfirewirefahsel Posts: 5
edited 2011-11-07 21:11 in Propeller 1
Hello guys,

I'm rather frustrated with myself, as I cannot seem to set any I/O ports to HIGH on the propeller beginner board (p8x32a). I have written the following code.
{Object_Title_and_Purpose}



CON
        _clkmode = xtal1 + pll16x                                               'Standard clock mode * crystal frequency = 80 MHz
        _xinfreq = 5_000_000




  
PUB LedOn
  dira[10] :=1
  repeat
    outa[10] :=1


DAT
name    byte  "string_data"        

It should make a high output on the 10th pin I would imagine, however, using a voltmeter, I have determined nothing is coming out. Am I configuring a cog wrong or something? Also, I'm assuming that the 10th pin is on the upper half of the fifth column on the female pin adapter black looking thing on the quick start board I have? I have tried a couple different pins, but can't seem to get it working;however, using that format of code, I have been able to turn an onboard LED on. Please help!


--Ryan

Comments

  • kuronekokuroneko Posts: 3,623
    edited 2011-11-07 00:38
    Check out this thread http://forums.parallax.com/showthread.php?134912-QuickStart-Labels, sounds like you got the location slightly wrong (upper/lower).
  • firewirefahselfirewirefahsel Posts: 5
    edited 2011-11-07 07:16
    I appreciate the response, but unfortunately no luck. Is it bad that I'm using a USB cable to power the board?
  • ElectricAyeElectricAye Posts: 4,561
    edited 2011-11-07 07:29
    ...I cannot seem to set any I/O ports to HIGH on the propeller beginner board (p8x32a)....

    Are you talking about the Quickstart board or the Protoboard or....???
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2011-11-07 07:36
    I see your problem, you are counting the pins from 1 to 10 but the ports start from 0 so therefore the 10th pin you are looking at could very well be P9 and not P10.
    (assumptions assumptions, I always thought it was way easier to just go and double check)
  • AribaAriba Posts: 2,690
    edited 2011-11-07 07:37
    I appreciate the response, but unfortunately no luck. Is it bad that I'm using a USB cable to power the board?
    No, USB is fine.
    Either you measure at the right pin, or you change your code to:
    ....
      dira[9] :=1
      repeat
        outa[9] :=1
    

    Remember that the pin numbers start with 0.

    Andy
  • Duane DegnDuane Degn Posts: 10,588
    edited 2011-11-07 07:46
    Ryan,

    Welcome to the forums.

    Lets make sure you get this working. The Propeller is a lot of fun.



    Pin 10 should be the sixth pin from the left on the front row on the female header.

    Try one of the pins with an LED attached. The code below should flash the LED in pin 16 (far right LED on QS board).
    PUB LedOn
      dira[16] := 1
      repeat
        outa[16] := 1
        waitcnt(clkfreq / 4 + cnt)
        outa[16] := 0
        waitcnt(clkfreq / 4 + cnt)
    

    Duane

    Edit: I see a bunch of other have helped while I was typing this.
  • firewirefahselfirewirefahsel Posts: 5
    edited 2011-11-07 08:18
    I really appreciate all of y'alls help. I have found the solution and feel like an idiot, but I want to fill everyone in in case another rookie makes the same mistake sometime. When I was testing the output voltage, I was using a ground on by breadboard. If you are going to test voltage on the board, you have to use VSS as the ground.

    I appreciate everyone's help!

    --Ryan
  • Duane DegnDuane Degn Posts: 10,588
    edited 2011-11-07 08:28
    Ryan,

    We've all done something like that.

    I'm glad you got it figured out.

    I've tried to gather some of the QuickStart projects I've seen or done myself in this thread.

    I also made some labels that you can see on the thread. They aren't as nice as the ones kuroneko linked to but I'm not sure if Phil is still making his labels.

    If you want a set of labels I made with my Brother label maker, just send me your address in a private message and I'll put a couple in an envelope and send them to you.

    Duane
  • firewirefahselfirewirefahsel Posts: 5
    edited 2011-11-07 08:54
    I appreciate the thought Duane, but I dont' want to hassle you, I can whip up some labels, but I'll use yours as a template!! I appreciate it. My last question. I just can't catch a break as a rookie ha. I'm trying to hook the Parallax RFID reader to the Propeller quick start board, and I seem to be habing issues. Everywhere on the internet, I can find tutorials on hooking up the RFID reader, but unfortunately not to the Prop quick start board. This is what I have so far.

    I have the VCC on the RFID going to a 5volt source on a bread board
    I have the GRND on the RFID going to to the ground of that source
    I have the /ENABLE hooked to the output on the prop board
    I have no idea where to put the SOUT pin.

    Even without the SOUT pin hooked up, I figured I should be able to "Enable " the reader which would turn the LED red on the RFID reader, however, it is always green. I don't know if I'm grounding something wrong on the RFID reader or something, but I'm not sure.

    I don't know if not having a common power source is an issue or what.

    This is the code I'm using:

    <CODE>{Object_Title_and_Purpose}



    CON
    _clkmode = xtal1 + pll16x 'Standard clock mode * crystal frequency = 80 MHz
    _xinfreq = 5_000_000





    PUB LedOn
    dira[1] :=1
    dira[0] :=1
    repeat
    outa[1] :=0
    outa[0] :=0


    DAT
    name byte "string_data"
    </CODE>

    I'm setting the output low, so it should enable the reader.


    Thanks,
    Ryan
  • Duane DegnDuane Degn Posts: 10,588
    edited 2011-11-07 09:04
    Ryan,

    It's okay to not have a common power source but you do need to a common ground. Just run a wire from the breadboard ground to a Vss connection on the QS.

    SOUT is usually serial out. You'd want to use a Prop pin as and input to read this. You probably want to use a serial object of some sort like FullDuplexSerial or Parallax Serial Terminal.

    The Propeller Education Kit (found under "Help" in the Propeller Tool) shows how to use asyncronous serial.

    Duane
  • AribaAriba Posts: 2,690
    edited 2011-11-07 10:09
    If you power the RFID reader with 5V you should add a resistor serially between the SOUT and the Propeller input pin. Use 2.2k or 4.7k or so.
    Otherwise the Propeller, running at only 3.3V, can get damaged.

    Andy
  • firewirefahselfirewirefahsel Posts: 5
    edited 2011-11-07 13:41
    Awesome! I think I'm finally in the right direction. I got the light to illuminate Red.

    Just so I'm not one of those people who blindly does without knowing, I wanna ask these two things:


    1.) Why is a common ground necessary if a power source doesn't have to be common. Shouldn't the grounds I'm using both be 0? Sorry to beat a dead horse, I just like to know why rather than memorize.

    2.) Also, I have read multiple places to put the 1k resistor in the SOUT, but I don't know why. I thought that a resistor limited current (V=IR), so how does that apply to the 5volt going down to a 3.3 v output. I'm sure you are right, I just would like to understand, so I don't always have to ask where to put resistors and can begin helping other people on these forums.

    3.) Can I use any input for the serial input or is there a specific one for serial input on the Prop board?

    Thanks in advance,
    Ryan Fahsel
  • Cluso99Cluso99 Posts: 18,069
    edited 2011-11-07 16:14
    firewirehahsel: Firstly welcome to the fabulous world of the propeller.

    To answer you questions..
    1. Positive voltages have to be referenced to something. That something is ground which is 0V. It is just like a battery... If you only connect the positive end, nothing will happen.
    2. The series resistor is between the prop pin and the "other chips pin". E=IR where E = volts, I = amps, R= ohms. When a current flows across the resistor, a voltage is dropped. So if you have 5V at one end of the resistor and 3V3 at the other end, you want to drop 1.7v. If you use a 4K7 (means 4.7K ohm but the K is moved to replace the "." so you do not miss the decimal) then you get I=E/R=1.7/4700=361uA. Similarly for 2K2 I=E/R=1.7/2200=773uA.
    Now in fact what really happens is that the protection diodes inside the prop on each pin protect the input pin when the voltage is above 3.3V (the supply voltage VDD because it could be different to 3V3). In fact this is somewhat above 3.3V because of the voltage drop. What this all means is that with a 4K7 this protection diode will pass about 361uA of current to the supply voltage. In one of the prop datasheets it specifies what these protection diodes can handle.
    3. Any prop pin can be used for serial input. However, P31 is typically used for serial input (and I gather your board has onboard USB so this pin is already used). It is preferable not to use P30 as this is normally an output for the download (P31 being the input). P28 & P29 are used with the eeprom and so cannot be used either. You will need to check your board to see what else is already being used.
  • JonnyMacJonnyMac Posts: 9,198
    edited 2011-11-07 21:11
    A lot of us started with BASIC Stamps and are used to instructions like HIGH, LOW, TOGGLE, etc. I have these methods in my programming template to replicate those instructions.
    pub high(pin)
    
    '' Makes pin output and high
    
      outa[pin] := 1
      dira[pin] := 1
    
    
    pub low(pin)
    
    '' Makes pin output and low
    
      outa[pin] := 0
      dira[pin] := 1
    
    
    pub toggle(pin)
    
    '' Toggles pin state
    
      !outa[pin]
      dira[pin] := 1
    
    
    pub input(pin)
    
    '' Makes pin input and returns current state
    
      dira[pin] := 0
    
      return ina[pin]
    
Sign In or Register to comment.