PDA

View Full Version : Unsolved Help With I/O Pins



firewirefahsel
11-07-2011, 08:18 AM
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

kuroneko
11-07-2011, 08:38 AM
Check out this thread http://forums.parallax.com/showthread.php?134912-QuickStart-Labels, sounds like you got the location slightly wrong (upper/lower).

firewirefahsel
11-07-2011, 03:16 PM
I appreciate the response, but unfortunately no luck. Is it bad that I'm using a USB cable to power the board?

ElectricAye
11-07-2011, 03:29 PM
...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 Jakacki
11-07-2011, 03:36 PM
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)

Ariba
11-07-2011, 03:37 PM
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 Degn
11-07-2011, 03:46 PM
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.

firewirefahsel
11-07-2011, 04:18 PM
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 Degn
11-07-2011, 04:28 PM
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 (http://forums.parallax.com/showthread.php?132216-Modified-QuickStart-Demos-and-QuickStart-Projects.).

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

firewirefahsel
11-07-2011, 04:54 PM
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 Degn
11-07-2011, 05:04 PM
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

Ariba
11-07-2011, 06:09 PM
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

firewirefahsel
11-07-2011, 09:41 PM
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

Cluso99
11-08-2011, 12:14 AM
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.

JonnyMac
11-08-2011, 05:11 AM
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]