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

Why this code does not work???

2»

Comments

  • RaymanRayman Posts: 14,162
    edited 2008-05-05 18:50
    Siri,

    I looked at it some more and I think I see your problem!

    You shouldn't be using the SERIN_DEC function from BS2_functions because that expects ASCII text ending in a <CR> character...
    But, your device is just sending 3 bytes of raw data (I think).

    So, just replace SERIN_DEC with SERIN_CHAR.

    The TV.dec function you already have with then display this byte as a number...
  • SiriSiri Posts: 220
    edited 2008-05-05 21:05
    Rayman,

    I got help from Parallax touse the scope and I think I got the answer you were seeking.

    Ihave attached the scope picture of the serial out-put from the serial device.I scoped all the 9 pins coming out of the serial device - what is attached is the out-put from Pin 2.Your hunch was afterall right- I still wonder why when the pin 3 is connected to BS2 and it works.

    As you can see the output Voltages are high and my guess is I will require the transistor circuit - like you advised with only the left transistor to feed the input to the PropRpm.I am planning to use different pin as I have some to spare and keep the built -in serial connection to connect to the PC.

    Please advise if my descion is -OK if not direct me in the right direction.

    Thanks once again for all the help.

    Siri
    2166 x 3370 - 1M
  • RaymanRayman Posts: 14,162
    edited 2008-05-05 21:42
    Siri,
    Read my last post! I think your real problem is with your code...
  • SiriSiri Posts: 220
    edited 2008-05-05 22:30
    Rayman,
    I will change the code as you suggested and will get back.
    Thanks,
    Siri
  • PropabilityPropability Posts: 142
    edited 2008-05-06 00:50
    Siri,

    If the PC(DTE) can talk to your device(DCE) and the PC(DTE) can talk to the PropRPM(DCE)· but the PropRPM(DCE) cannot talk to the device(DCE) then I would think you need what is called a null modem cable. Sounds like you have a 'straight trough' cable (pin 2 to pin 2 and pin 3 to pin 3) . A null modem cable would have pin2 going to pin3 and vice versa.
  • SiriSiri Posts: 220
    edited 2008-05-06 17:38
    Pete,

    ·You are absolutely right - I made a new cable switching the pins ·2 & 3 and now I am receiving data - but the new problem is they are not same decimal numbers they are suppose to be.

    I tried inverting the signal - still I get data but they are not right.

    What is this new problem - ? code.

    Thanks,

    Siri
  • PropabilityPropability Posts: 142
    edited 2008-05-06 18:02
    Siri,

    If you can receive the data correctly with the software provided for the device and by the rs232 analyzing software but NOT by hyperterminal correctly then I would guess that the way the data is presented to hyperterminal is the way your program is trying to read it also. Have a look at what is actually being received by the analyzing software.

    Pete
  • SiriSiri Posts: 220
    edited 2008-05-06 22:45
    Rayman/Pete

    After I switched the P2&P3· and changed the code of the BS2 calls to "serin_char" as you suggested.

    Now it shows incorrect decimal values.

    I was using a trial version - "serial port analyser"- and the function I need is blocked.So when I get a

    fully working software version,I will get back to you.

    Thanks for the help.



    Siri
  • PropabilityPropability Posts: 142
    edited 2008-05-06 23:55
    Siri,

    Here is a link to that terminal program that I mentioned.It works very well at seeing what is happening on your rs232.

    http://braypp.googlepages.com/terminal

    Pete
  • RaymanRayman Posts: 14,162
    edited 2008-05-08 00:01
    One other thing to look at is if the signal is inverted or not. You could just try both inverted and non-inverted modes in the SERIN_CHAR function's mode parameters. You can also tell this by using your scope on PIN31 to see what the signal looks like.

    Also, once you get the signal on Pin31 of the Prop (like you showed above), you can actually read the data right off the scope screen...
  • SiriSiri Posts: 220
    edited 2008-05-08 14:25
    Rayman,

    I tried inverting the signal - still not correct data,tried different parity - not successful.

    The data coming out of the serial device· when connected toa serial devise analyser is: 96000 8N1 - the out put is "Decimal" - with the correect data.

    I will try to read the Data off the scope ? this p.m and will get back to you.

    Thanks for taking all this time to help me.

    Siri
  • SiriSiri Posts: 220
    edited 2008-05-08 22:22
    Rayman/Pete,
    I have finally able to display the correct data on the screen.
    The final solution was swapping the pins 2&3, inverting the signal and routing the signal via the DB9 - port in the PropRPM.
    Although I can get the signal via the transisitor circuit to the PropRPM but was not able to get the correct data display.

    Now that I have accomplished what I was after now I can proceed to the next step in my project.

    I am very thankful to both of you for your extrodinary ability to stick with me to and to guide me along to resolve the issue.
    I learned a lot about serial communication and as an additional bonus learned fast lesson on how to use a scope to read a serial signal.

    Thank you

    Siri
Sign In or Register to comment.