Shop OBEX P1 Docs P2 Docs Learn Events
Why this code does not work??? — Parallax Forums

Why this code does not work???

SiriSiri Posts: 220
edited 2008-05-08 22:22 in Propeller 1
I am trying to display output from a serial device - which sends out 2 bytes of data.The device works well and when the out put is captured using BS2sx works ok.
When I use the propeller - "PropRPM" the attached code only displays "Display O2 sat data in ASCII" text only.
NO serial data is displayed at all.

Please can someone show me why?

Thanks
«1

Comments

  • RaymanRayman Posts: 14,233
    edited 2008-04-29 18:48
    code looks ok as far as I can tell (but I don't really use BS2 functions)....
    You might try changing:
    RxData1 := BS2.SERIN_DEC(RX_Pin,Baud,1, 8)
    to
    RxData1 := BS2.SERIN_DEC(RX_Pin,Baud,0, 8)
    just in case you signal is inverted somewhere...

    also, for troubleshooting, maybe try
    RxData1 := 5
    and be sure it shows "5" on the monitor.

    You might consider using "fullduplexserial" instead of BS2 functions if you still have problems. It's also pretty easy to use.
  • SiriSiri Posts: 220
    edited 2008-04-29 19:19
    Rayman,

    ·I tried using "·RxData1 =5" ,"Rxdata2=10" and I can display the numbers on the screen.

    I also used "FullDuPlexSerial",:ExtDuplexSerial","Simple Serial" - objects. with all of them do·NOT seem to receive any serial data.

    I am using the"PropRPM" with the built in serial interface using the "MX2232" chip.

    The Basic Stamp set-up I am using the serial data is sent directly from the serial device to the BS2px ·pin using "SERIN command".

    Does this have antthing to do with this problem.

    Can I use a 10K resistor and directly feed the serial out put from the serial device to the "Prop Pin-31" as I only require the serial out-put from the serial device.

    Thanks for the quick reply.

    Siri

    P.S - serial device still works well with BS2 set-up.
  • Mike GreenMike Green Posts: 23,101
    edited 2008-04-29 20:07
    You should describe your connections in much more detail (like with a schematic). If you connected the MAX3232 chip to a BS2px pin without a series resistor as described in the BASIC Stamp Manual, you may have destroyed the I/O pin. Theoretically, you could connect the serial output through a 10K resistor to a Propeller I/O pin and the resistor should protect the I/O pin, but it may not work well depending on the speed, voltage range, etc. I don't recommend it. Use the transistor circuit shown in the Propeller manual or a 3.3v logic to RS232 converter chip like the MAX3232.
  • RaymanRayman Posts: 14,233
    edited 2008-04-29 20:27
    Ok, I think I see your problem... The MAX3232 is there to convert PC level RS232 signals (+/- 10V) down to TTL levels. But, is sounds like your serial device is already at TTL levels. So, you want to connect this directly to a prop pin. But, maybe you should use a 1k or so series resistor just for safety. I think your proprpm thing has plenty of spare pins, so you might want to use a different one, besides 31,30.
  • SiriSiri Posts: 220
    edited 2008-04-29 22:43
    Mike/Rayman

    I am connecting the DB9 connection from the serial device to the DB9 in the "PropRPM".

    I have nothing else connected.



    Rayman - I will try your solution.Is there a way to·check the out-put with a Digital voltmeter to

    see whether it is TTL or not.

    Thanks

    Siri
  • Mike GreenMike Green Posts: 23,101
    edited 2008-04-29 23:04
    Siri,
    Measure the voltage at the output. If the resting or idle voltage is +5V, it's probably TTL.
  • RaymanRayman Posts: 14,233
    edited 2008-04-29 23:23
    Also, I think if you had it going straight to a BS2 pin before, it must be TTL...
  • SiriSiri Posts: 220
    edited 2008-04-30 00:32
    Mike/Rayman,

    Thank you very,very much for such prompt replies.You all are agreat help for week-end amature electronic hackers like me who has no formal training.

    I will try what both of suggested and will post back with the results.

    Thanks again.

    Siri
  • SiriSiri Posts: 220
    edited 2008-04-30 01:32
    Mike/Rayman,

    The voltage between pin-2(Rx) and pin-5(gnd) of the DB-9 is 8.7V. coming from the serial device.

    Please advise.

    Thanks,

    Siri
  • SiriSiri Posts: 220
    edited 2008-04-30 02:15
    Mike/Rayman,

    I measured again - the measurements are very confusing anyway here they are :

    ····· 1.DB-9 pin2(Tx)· and pin 5-Gnd --->8.7V ----> This is Tx coming out of BS2 pin

    ····· 2DB-9 pin3 (Rx) and pin5(Gng) --->0.001V ---> this is the Rx going to the BS2 pin

    I measured them after removing the BS2px chip - measured at the DIP socket

    I am very confused now.
    Please advise.

    Thanks

    Siri
  • RaymanRayman Posts: 14,233
    edited 2008-04-30 03:24
    Oops, I see now that the BS2px has a built-in level shifter for serial data. So, it sounds like you do need the MAX3232. Connecting your serial data line directly to a Prop pin would not be a good idea!

    So, I guess I don't know why your original code didn't work...

    Post Edited (Rayman) : 4/30/2008 3:39:34 AM GMT
  • SiriSiri Posts: 220
    edited 2008-04-30 15:27
    Mike/Raymond,

    I connected the serial out-put straight to the computer and then tried to capture the data via the Hyperterminal and I get all garbage and NO decimal out-put.The connection parameters are correct - "9600,8,N,1 " as stated in the instructions with the serial device.

    When I fired up the software that came with it - I get decimal out-put as it is supposed to - which I also get from my BS2px st-up.

    Then I used RS232 port analyzer software - which also worked well and diaplayed the decimal out-put correctly.

    As far as I can see the hardware is connected OK.Only the·?" PropRPM" and ? Hyperterminal has issues.

    I hope one of you can solve this.

    Thanks again

    Siri
  • RaymanRayman Posts: 14,233
    edited 2008-04-30 17:57
    I think you're going to have to post some more information about the device/protocol.· Maybe you can post some of the BS2sx code that is working...

    It may be that the decimal output you're looking for would look like junk on the Hyperterminal screen.· But, at least you get some output from your device with Hyperterminal.· You should get something with your setup too...

    Maybe there's something strange about the PropRPM platform...· I'm not too familiar with that...
  • SiriSiri Posts: 220
    edited 2008-04-30 19:12
    Rayman,

    ·Thanks for helping me.

    Please find the attached specs for the serial device.

    Siri
  • RaymanRayman Posts: 14,233
    edited 2008-04-30 19:27
    Ok, that describes TTL-like serial siganl coming out of a pin. How is this connected to the DB9 connector? Is it a direct connection? Or, is there an IC chip there to boost to PC-RS232 levels?
  • SiriSiri Posts: 220
    edited 2008-05-01 00:57
    Rayman,

    It is attaced to the DB9 via - chpi # LTC1382CSW.

    I have attached the data sheet for you.

    Thanks for all this.

    Siri
  • RaymanRayman Posts: 14,233
    edited 2008-05-01 01:37
    Everything looks OK then. So, you have me stumped as to why it's not working... This is the point where I'd break out an oscilloscope to track down the issue...
  • SiriSiri Posts: 220
    edited 2008-05-01 13:50
    Rayman,
    I just received the "Parallax USB Scope" and was just reading the intro., so you can see I am very,very
    fresh at this.
    If you can just point me what I should do with the scope I will be glad to follow your instructions.This will not only solve the problem but will also be a very good lesson in oscilloscope usage.

    Thanks

    Siri
  • RaymanRayman Posts: 14,233
    edited 2008-05-01 15:39
    Well, I would just look at pins 2 & 3 of the DB9 connector you are connecting to the PropRPM.· One of them should show serial data coming in...· Should look something like this:

    -------+   +-+ +-+   +---------
           |   | | | |   |
           |   | | | |   |
           |   | | | |   |
           +---+ +-+ +---+
    

    I guess you should get 3 bytes like this every second...

    I think the high level should be 10V and the low level might be 0 or -10V...

    Then, hook it up to your PropRPM and look at pin31.· You should see the same type of signal with a high voltage of about 3.3V and a low voltage of 0V...
  • RaymanRayman Posts: 14,233
    edited 2008-05-01 15:50
    One thing I'd look for is the serial data coming in on the wrong pin...

    It needs to be on pin3 of the DB9 connector, but maybe it's on pin2 for some reason... If so, need a null-modem like adapter to swap pins 2&3...
  • SiriSiri Posts: 220
    edited 2008-05-01 21:53
    Rayman,
    Measring the out-put from the serial device furhte confused me - may be I was doing it incorrect - with the scope.I seem to get a better signal on P2 rather than P3 - of the DB9 coming out of the serial device.
    Then I double checked the connections to BS2 set-up.I have P3 connected and not P2 from the DB9.

    Thank you very very much for all the help you have given me.
    I will get bak with you when I acquire little experience with the scope so I know what I am doing with it.
    If you would like I willget back with you sometime.

    Siri
  • SiriSiri Posts: 220
    edited 2008-05-01 23:44
    Rayman,
    I am planing to connect the serial output directly to the propeller to see if it si gong to work - sine it works with the BS2.
    To do so what would be the best way - I know I might damage the prop - that is a chance I am willing to take.

    Thanks

    Siri
  • SiriSiri Posts: 220
    edited 2008-05-02 00:36
    Rayman,

    I found this circuit in the forum -" Serial to Propeller Connection Schematic" - may be I will try connecting the serial device as per this doc.

    See attachment.



    Siri
  • RaymanRayman Posts: 14,233
    edited 2008-05-02 00:47
    That circuit should work. You just need the transistor on the left. Note that the circuit inverts the polarity of the signal, but I think the BS2 functions and fullduplexserial expect this, or at least have a option to correct for it.

    You might try connecting directly with a 10k resistor. But again, you may have to account for the polarity of the signal.
  • PropabilityPropability Posts: 142
    edited 2008-05-02 02:16
    If you already have been able to talk to the device thru rs232 using the provided software and also to the BS2 thru your program it seems just a matter of getting the level conversion correct and making sure the max232 clone(LTC1382) is working correctly. The LTC1382 has a pin(pin 18) that must be pulled high for it to not be tri-stated.

    A simple test that can be done with rs232 is the loopback hookup. Say you want to have hyperterminal receive characters that you type on the keyboard as input .This can be done by connecting the TX to the RX pin which just loops the data back into hyperterminal.

    So let's say you want to test your max232 clone circuit . There are two rs232 circuits so you can form a type of loopback test. One rs232 circuit(maybe pins 8and 9) goes to your computer running the software that works and the other rs232 circuit(pins 14 and 15) goes to your device(blood monitor) that your are trying to interface to.

    The logic side of the max232clone would have pins 10 and 12 hooked together and pins 11 and 13 would be tied together to form a loopback circuit . This is from the datasheet that you provided.

    If the max232 clone is working correctly then you should see the data , if not then your hookup of the chip should be examined closely.
  • SiriSiri Posts: 220
    edited 2008-05-04 16:18
    Rayman,
    ············ I am still unable to capture the serial out-put from the device to the propeller.I tries the transistor circuit using only the the left transistor.I still have to try connecting directly via 10K resistor.In the mean time I have been playing with the scope.
    Attached is a picture of the scope wave form and readings.
    Thw wave form does not look like the ones in the book· or the one you depicted.
    The out put from the device is at 9600,8N1

    I can see the out-put at 1.0Htz - frquency.What does all this add upto.
    Hoprfully this will give you more info to resolve this issue.

    Thanks,
    Siri
    2303 x 3315 - 1M
  • RaymanRayman Posts: 14,233
    edited 2008-05-04 17:34
    you're just looking at 60hz noise there... Maybe you didn't hook up the ground connection to the scope input correctly... Also set your trigger threshold (I'm assuming that thing has a trigger) so that you don't trigger off noise, but only the signal you're looking for.

    Since your questions are about all Parallax sold products, you might try calling or emailing their support line... Might get there faster that way...
  • SiriSiri Posts: 220
    edited 2008-05-04 22:05
    Propability,
    The serial devise I have is fairly expensive and opening it will void my warrenty and peeping from the openings - the components
    seem to be SMD's so I really would not wan't to monkey with it.
    Rayman - I will call parallax to-morrow to seek some advise.

    Thanks for both of you to taking time to help

    Siri
  • PropabilityPropability Posts: 142
    edited 2008-05-05 03:51
    Siri

    I thought you had made your own interface using the max 232 clone chip and not a manufactured one. Having looked at the Proprpm it already has the max 2323e chip used for·programming the prop. If you can download programs to the Proprpm then you already have your rs232 comm's working.All you really need is to work out your protocol with your device. To test out the rs232 there are several objects that allow you to send from the prop to the PC and vice versa ·thru the rs232. I like Brays terminal as· program which is a free download.



    Pete
  • SiriSiri Posts: 220
    edited 2008-05-05 18:00
    Pete,

    I can send data from the PC to the PropRPM - I can download the spin code from the PC to the PropRPM.

    I can also also see the data out-put from the serial device when connected to the PC - using either using the software that came with the Serial device and also when using a serial port analyser software but not with the Hyperterminal and ·when I connect the derial device to the PropRPM via the serial port - the prop does not see the data.

    The spin program seem to working well otherwise except is unable to recive the data - all I can see is "000" and displays other " text" without any problems.NO decimal serial data that show up in the PC when connected directly to the serial device.

    I will download the program you suggested and see what happens.



    Thanks

    Siri
Sign In or Register to comment.