Shop OBEX P1 Docs P2 Docs Learn Events
Alternative Rs232 propeller Interface — Parallax Forums

Alternative Rs232 propeller Interface

christopherchristopher Posts: 31
edited 2007-02-06 16:40 in Propeller 1
Hi,

I have built and successfully used the three transistor interface circuit for the propeller featured on this site. However, when I use the same circuit from a separate cog, I am finding that the when the circuit is connected to the PC with the pc tx driving at -10 volt it works fine but when disconnected from the PC it seems that the cog detects a low going pulse and this traps the cog as it waits for further serial data input.

Has this been experienced and does max3232 solve this problem ? Can the problem be solved with discrete transistors ?


Thank You

Chris

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2007-01-18 02:09
    The three transistor interface includes a reset circuit. It may be that your Propeller is getting reset when it's disconnected or connected to the PC. The solution is to put a jumper or switch into the reset line from the 3rd transistor. It is possible to inhibit the reset signal using another pin on the Propeller and some additional external circuitry. I don't think switching to a MAX232 will help unless the reset issue is addressed.
  • christopherchristopher Posts: 31
    edited 2007-01-18 02:24
    Many thanks for the quick response. But I am finding that using discrete level translator with transistor and 4.7k pull up to 3.3v propeller input seems to be giving a false transient which the prop interprets as the start of serial data. Is the prop so sensitive

    Chris
  • Mike GreenMike Green Posts: 23,101
    edited 2007-01-18 02:53
    The Prop is pretty sensitive. It's logic threshold is about 1/2 the supply voltage or about 1.65V. I'm not sure I'd call this a false transient. It may be an unintended one. I don't know what serial driver you're using, but the usual behavior when they see a transient high to low level is to consider this a start bit and time the other serial bits from that point, thus producing a single character. You could write your own serial driver that samples the input line several times after a high to low level and requires that it see several samples all with logic low values before it calls this a start bit, then continues timing from the initial high to low transition. A number of UARTS do this for reliability. None of the current Prop serial drivers do this.

    At low speeds (19.2KB or less), you could start with the Simple_Serial driver which is all in Spin.

    Try the attached serial driver. I added some code to the receive routine that checks at 1/4 bit time and 1/2 bit time from the leading edge of the start bit. If the serial line is high, it wasn't a start bit really and the routine waits for the next high to low transition. I haven't tried the routine, but it should work as modified.

    Post Edited (Mike Green) : 1/18/2007 3:25:55 AM GMT
  • christopherchristopher Posts: 31
    edited 2007-01-18 16:40
    Mr Green,

    Many thanks for your assistance I shall implement same. Allow me to allow take advantage of your good nature. I am in fact using the simple-serial.spin at 4800 baud, but the routine awaits a start bit. I would like to implement a time out in the event that the remote pc does not deliver after a specified time. Is there such a routine or should I·adjust simple-serial to timeout and return.


    You've just helped a guy in Trinidad· W.I (yeah it's warm)

    Thanks,

    Chris
  • Mike GreenMike Green Posts: 23,101
    edited 2007-01-18 16:52
    The way the simple serial is written, it uses the WAITPEQ instruction to wait for a start bit and the cog stops waiting for that bit transition and, as you have noticed, won't do anything else until a character comes in. The simplest solution would be to use the FullDuplexSerial object from the Propeller Object Exchange. This is more complex, but does implement a fully buffered serial connection. It would allow your program to continue doing other things while part of the object runs in a separate cog waiting for a serial character. Your main program can check whether something has been put into the buffer without waiting if there's nothing received yet. You can also shutdown and restart the software UART if it gets hung up somehow. Download the object and have a look at it and the demo program that comes with it.

    It is possible to do the same kind of thing with the simple serial routines (make the receiver and transmitter run in a separate cog with a simple buffer), but the FullDuplexSerial object already has been written and works well.
  • christopherchristopher Posts: 31
    edited 2007-01-18 20:31
    thanks

    Again

    Chris
  • squidxsquidx Posts: 33
    edited 2007-01-26 06:01
    Hi, I'm looking for some advice on communicating between the Propeller Demo Board and a Peter Norton (stepperboard.com) BS0710 stepper motor control board. I'm brand new to the serial communications on these boards, so please bear with me.

    I have a stepper board set up with a motor so that I can send serial strings to it through Windows Hyperterminal and have it do things. These strings are very simple. For example, I can send it "+s" (slew) and the motor will just start spinning until I send it "z," which will stop it. Great. Now it's time to get Propeller to do it.

    The board has a Serial In pin, and I have gleaned that I can try to use Simple_Serial or maybe FullDuplexSerial (overkill? I'm not rx-ing at all yet!). In this scheme, I should just make sure both boards are sharing ground and then connect the Serial In pin to some pin, say pin P1 on the Propeller Demo Board, call Simple_Serial simply, and send it the string to send. So I've tried it, and it isn't doing anything.

    Any advice? Did I miss an important concept? Here's all of the code I think it should take. If anyone can straighten me out, I'd really appreciate it.

    ' testing simple_serial
    ' need to make an object to start it
    ' then send it the string...
    '
    obj boardcom: "Simple_Serial"
    '
    Pub start
    · boardcom.start(-1,31,9600)······· '(rx pin, tx pin, rate) -1 for fake rx
    '
    · boardcom.str(string("+s"))········'send slew command



    Alex
  • QuattroRS4QuattroRS4 Posts: 916
    edited 2007-01-26 07:10
    CON
    _clkmode = xtal1 + pll16x
    _xinfreq = 5_000_000

    OBJ
    ExtSerial : "FullDuplexSerial"

    Pub Test
    · extserial.start(8, 7, 2, 9600) ' rxpin,txpin,mode,Baud - depends on your set up

    repeat 10 ' repeat 10 times
    · extserial.str(string("+s")) 'slew
    · waitcnt(20_000_000 + cnt) 'wait a length of time while slewing
    ··extserial.str(string("z,")) ' stop I PRESUME THE COMMA IS INTENTIONAL in your example
    · waitcnt(20_000_000 + cnt) 'wait stopped for a while




    if CR - carriage return is required after the command -·mod the line of code this way

    extserial.str(string("+s",13)) 'slew

    or 10 for line feed..

    Let me know how you get on..

    - yeah just typed it in so corrected now

    Post Edited (QuattroRS4) : 1/26/2007 4:52:31 PM GMT
  • squidxsquidx Posts: 33
    edited 2007-01-26 16:38
    Thanks Quattro,

    I tried it, without my typo comma, and it was down a couple of ")", but got that worked out easily. No result, though, so I need to check on my mode, and if I'm set up right on the other side. Have you used this board before, by any chance?

    I appreciate the help. Wish I saw it last night!
  • QuattroRS4QuattroRS4 Posts: 916
    edited 2007-01-26 16:58
    Nope haven't used it but if hyper terminal works - then the example should.

    try adding CR & LF

    extserial.str(string("+s",13,10)) 'slew

    I had a silly interface before that required LF then CR maybe worth bearing in mind.

    Did you SEND to hyper terminal from prop - to see if you are outputting OK ?

    Doing that you can work out the mode that suits you best - mode 2 for me on laptop - Have also used mode 1 on other machines.

    Let me know how you go...
  • QuattroRS4QuattroRS4 Posts: 916
    edited 2007-01-26 17:06
    With regards to the first post - I have built a Max232 based serial interface - uses 1 transistor for reset and there is no issue.Image ,datasheet and link attached.

    Actually it is a ST microelectronics example 3v -5.5v type - see attached pdf.

    Follow the link to the prop stick to see connections -

    http://www.parallax.com/dl/docs/prod/prop/PropStick-v1.2.pdf







    Post Edited (QuattroRS4) : 1/26/2007 5:19:14 PM GMT
    640 x 480 - 69K
  • squidxsquidx Posts: 33
    edited 2007-01-30 16:50
    Quattro, when you send to hyperterminal using Prop, what is the physical interface? Do you use the USB connector? Or do you hook it to a traditional serial cable to the computer? That sounds like an excellent solution for testing.

    Thanks,

    Alex
  • QuattroRS4QuattroRS4 Posts: 916
    edited 2007-02-06 01:36
    Squidx,
    Used a breadboarded prop with 232 driver as mentioned and traditional 'null modem' (3wire) serial cable - rx,tx,gnd..

    Have used it without support I.C· - no problems to traditional serial port (resistors are recommended) - but find that without the driver - I have had issues with some USB to serial devices ...

    Quattro

    Post Edited (QuattroRS4) : 2/6/2007 1:51:45 AM GMT
  • QuattroRS4QuattroRS4 Posts: 916
    edited 2007-02-06 16:40
    squidx

    Personally I would prefer to use a 232 driver - but further to your query -


    I ran a trial just now for you - using a demo board - to a laptop which has a third party usb to serial device as its serial port.

    connections as follows - Vss on demoboard to pin5 (gnd) on p.c serial port
    P0 on demoboard through a 4.7K resistor to pin 2 on P.C serial port

    On the pc start up hyperterminal - 9600,N,8,1 and flow control 'None'

    Do the following with the Propeller IDE -

    CON
    _clkmode = xtal1 + pll16x
    _xinfreq = 5_000_000

    OBJ
    ExtSerial : "FullDuplexSerial"

    Pub Test1
    extserial.start(-1, 0, 2, 9600) ' (transmit only)- rxpin,txpin,mode,Baud - depends on your set up

    repeat 5 ' repeat 5 times
    · extserial.str(string("Hello World 'concatenating' "))
    · waitcnt(100_000_000 + cnt) 'wait a length of time
    extserial.str(string(13,10)) 'move to new line
    repeat 5
    · extserial.str(string("Hello World in a new line each time!",13,10))
    · waitcnt(100_000_000 + cnt) 'wait a length of time

    You should see the results in hyperterminal window.

    You may have to adjust the 'Mode' to suit your needs .... mine worked in both modes 2 and 3
    Let me kow..

    Quattro

    Post Edited (QuattroRS4) : 2/6/2007 7:57:10 PM GMT
Sign In or Register to comment.