Shop OBEX P1 Docs P2 Docs Learn Events
Serout a variable or pin state — Parallax Forums

Serout a variable or pin state

CastrovinciCastrovinci Posts: 26
edited 2006-01-14 06:24 in General Discussion
Hello,
· I have searched the forum many times and have·seen example code to serout a variable or pin state.· I tried using the programs john has provided and hitt consulting.· It always send the hex format (Or not the actual number) or·variable I try to send.· For example

DEVICE SX28, OSCHS3, TURBO, STACKX, OPTIONX
FREQ 50_000_000

InPin VAR RB.0 ' Change this to whatever pin you want to monitor
SOutPin VAR RB.1 ' Change this to whatever pin you want serial output from

Temp VAR BYTE

PROGRAM Start

Start:
· INPUT InPin

Again:
· Temp=InPin
· SEROUT SOutPin, N115200, Temp
GOTO Again

This should send a either a 1 or a·0 out.· However I get a smiley face or some other character.· I have changed the baud rate even to 2400 it does the same.··It wont send any characters unless I·switch to N2400 instead or T2400.· The hardware connection I have it a serial plug with the serout pin connected to it and hyperterminial connected.· It is also grounded to the·ground.· The pin I am using on the serial cable in number 2 for the connection and number 5 for the ground.· I can send·one letter at a time using·this format:

Serout Ra.0,·N2400, "A"

But I need to send the pin state·and a variable seperatly

Serout Ra.0, N2400, Variable

I am using an external osc like you said and I tried·all different freq and resinators.· Can you please help I am·semi new to this chip.· ·

In Short It must always be in "" for numbers to be sent or words.· Which I need to send variable data.·

Thanks again!
Tony
burger.gif

Comments

  • BeanBean Posts: 8,129
    edited 2006-01-13 02:12
    Tony,
    · Welcome to the forums...
    · Change Temp=InPin to Temp=InPin+"0"
    · There is a difference between the value 0(zero) and the character 0(zero). It happens that the character 0(zero) has a value of 48, and the character "1" has a value of 49.
    · So you have to add the value of the character 0(zero) to your bit value.
    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "SX-Video·Module" Now available from Parallax for only $28.95

    http://www.parallax.com/detail.asp?product_id=30012

    "SX-Video OSD module" Now available from Parallax for only·$49.95
    http://www.parallax.com/detail.asp?product_id=30015

    Product web site: www.sxvm.com

    "Ability may get you to the top, but it takes character to keep you there."


    Post Edited (Bean (Hitt Consulting)) : 1/13/2006 2:16:31 AM GMT
  • CastrovinciCastrovinci Posts: 26
    edited 2006-01-14 03:53
    Hello again bean,

    First of all thank you soooo much beacuse the above code now works.· However I have another problem, This program I created, which I will list below sends each pin state seperatly, I need to have the four pin states that I choose sent at once.· I found another program you wrote earlier that goes like this, but it does not work.· It sends nothing.·

    DEVICE SX28, OSCXT2, TURBO, STACKX, OPTIONX
    FREQ 4_000_000

    inport var RC
    soutpin var RB.0

    Program Start

    Start:
    Serout soutpin, n2400,inport
    goto start

    I can go the route of all pins being sent at once but I can not get the program working.· My program goes like this:

    DEVICE SX28, OSCXT2, TURBO, STACKX, OPTIONX
    FREQ 4_000_000

    InPin3 VAR Ra.3 ' Change this to whatever pin you want to monitor
    inpin2 var ra.2
    InPin1 VAR Rc.7 ' Change this to whatever pin you want to monitor
    inpin0 var rc.6
    SOutPin VAR Ra.0 ' Change this to whatever pin you want serial output from
    pins2 var byte
    pins3 VAR BYTE
    pins1 var byte
    pins0 var byte
    pinto var byte
    PROGRAM Start

    Start:
    · INPUT InPin3
    · input inpin2
    · input inpin1
    · input inpin0
    · plp_A.3
    · Plp_A.2
    · plp_c.7
    · plp_c.6
    Again:
    · pins3=InPin3+"0"
    · pins2=inpin2+"0"
    · pins1=inpin1+"0"
    · pins0=inpin0+"0"
    · SEROUT SOutPin, n2400, pins3
    · Serout soutpin,n2400, pins2
    · SEROUT SOutPin, n2400, pins1
    · Serout soutpin,n2400, pins0
    ·GOTO Again

    In Short I need it to send 1100 then send

    instead of 1 send

    ·············· 1 send

    All Pin states need to come at once.

    You are the man so any suggestions?

    Thanks,

    Tony Castrovinci

    rolleyes.gif
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-01-14 04:52
    Here you go, Tony, give this a try -- I've run it on my PDB and it seems to do what you want.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • CastrovinciCastrovinci Posts: 26
    edited 2006-01-14 05:38
    Ok, You Guys are AMAZING. IT IS EXACTLY WHAT I NEEDED, and for you to take the time out to design a program and in such a quick time deserves lots of respect. I will pass the same on by helping, in posting to another members question(s)

    Thanks again,
    Tony Castrovinci
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-01-14 06:24
    Actually, it didn't take any time at all -- I already had all those routines from other programs. Have fun!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
Sign In or Register to comment.