Shop OBEX P1 Docs P2 Docs Learn Events
Reading smart motor data with db9 through max232 — Parallax Forums

Reading smart motor data with db9 through max232

Hello,

I am not doing so well with this yet. I have a PTP
http://www.rayslogic.com/propeller/Products/PTP/PTP_Schematics.htm
And all I want to do is read velocity from a smart motor rs232 output.
The smart motor db9 is connected into a max32.
I have the gnd and 5v of out of the max232 coming into the board with the Q44 Propeller Parallax chip on it
going to V5 and Gnd. I also have the TX going to P4 and Rx Going to P5 on this board because my usb from my computer
is inserted into the board, so that takes care of my onboard tx rx going directly to the Q44 chip.

I have tried different UART commands. And this is my code for now which all it does is display the velocity text but I want to
know what is coming out of the tx of my db9, and read it back to the display for velocity.

Here is the code so far. Maybe over kill but a co-worker gave me quite a bit of code to start with which included
Xbee functions and numchuck info which I took out. I only want to read the velocity value coming out of of the db9 Tx port.

I just do not know what to do next. Any help steering me in the right direction would be helpful.

Thank you

Comments

  • mechqueen wrote: »
    I also have the TX going to P4 and Rx Going to P5 on this board because my usb from my computer
    is inserted into the board, so that takes care of my onboard tx rx going directly to the Q44 chip.

    I haven't looked at the code yet but I wanted to warn you about using 5V logic signals with the Propeller. You need at least a 3.3K resistor in series on the rx line from the MAX232 chip.

    I'll take a look at the code a bit later if no one else beats me to it.

  • Yes, thank you. I already do have a resistor in series with the rx line which is bringing my voltage down to 3.30. :)
  • Duane DegnDuane Degn Posts: 10,588
    edited 2016-09-07 18:54
    I haven't tested this but it should let you see any non-printable characters.
    CON
    
      _clkmode = xtal1+pll16x
      _clkfreq = 80_000_000
    
     
    
    CON
                                      'Note Clock Speed for your setup!!
    
        COM11_RX = 4
        COM11_TX = 5
    
        COM12_RX = 31
        COM12_TX = 30
    
        BAUD_RATE = 9600
        
    
        
    OBJ
      uart1     : "FullDuplexSerial"
      uart2     : "FullDuplexSerial"
    
    PUB Main
    
    
      uart2.start(COM11_RX, COM11_TX, 0, BAUD_RATE)
      uart1.start(COM12_RX, COM12_TX, 0, BAUD_RATE)
    
      repeat
        result := uart2.rxCheck
        uart2.str(string(11, 13, "Press Any Key"))
        waitcnt(clkfreq / 2 + cnt)
      while result == -1  
    
      uart2.tx(16)  ' clear screen
      uart2.tx(1)   ' home
      uart2.str(string(11, 13, "Data Logger v.1"))
      uart2.tx(11) ' clear end of line
      uart2.tx(13)
    
      'echo everything out
      repeat
        result := uart1.rx
        SafeTx(result)
         
    
    PUB SafeTx(character)
    
      case character
        13:
          FramedHex(character)
          uart2.tx(character)
        33..126:
          uart2.tx(character)
        other:
          FramedHex(character)
    
    PUB FramedHex(character)
    
      uart2.tx("<")
      uart2.tx("$") 
      uart2.hex(character, 2)
      uart2.tx(">")
    
  • Oh wow. Thank you. I will see how this works and post back.
  • I just noticed a mistake. That's what I get for not testing it. I'll fix in a few minutes.
  • I fixed the embedded code above and I've attached the corrected Spin file to this post.

    I still haven't tested the code but this version has a better chance of working.
  • Cluso99Cluso99 Posts: 18,069
    I have the gnd and 5v of out of the max232 coming into the board with the Q44 Propeller Parallax chip on it
    going to V5 and Gnd.

    I do hope you are using 3V3 on the propeller chip???

    I see the schematic shows all 4 sets of power and ground are connected and with bypass capacitors. I presume you have a propplug to program your propeller (It appeared to be a separate connector on the schematic. If you build your own propplug you will need the transistor reset circuit. I like a 10K pullup on the prop RST pin as it helps to prevent noise causing an unwanted reset.
  • Is there any difference between using a modern MAX232 variants vs the older ones. The new ones all point to a datasheet that is over 20 years old! see attached PDF file. I'm guessing it's just to conform to RoHS.

  • You probably should use a max3232, which is made for 3.3v instead of 5v.

Sign In or Register to comment.