Shop OBEX P1 Docs P2 Docs Learn Events
FullDuplexSerial and Serial Component — Parallax Forums

FullDuplexSerial and Serial Component

pattywacpattywac Posts: 22
edited 2012-03-10 19:51 in Propeller 1
Hello Everybody,
I am pretty new to the prop and could use some help. I am trying to use the FullDuplexSerial code to send a specific hex value ($56002600) to the component (linksprite jpeg camera) and should be receiving a specific message back from the camera ($76 00 26 00).

I am fairly confident that I have everything wired up correctly, but less sure of my code. I seem to be receiving bytes back, but they are all ($FF) or at least the way I'm reading the rx they are all ($FF).

I've included my code below and here is the repeating response that I get via the terminal window :
Hex test FFFFFFFF

If I'm doing anything blatantly wrong, please point it out.... otherwise, any ideas why I might not be getting the right signal back?

Thanks!
Con

  _clkmode = xtal1 + pll16x
  _xinfreq = 5_000_000

OBJ
  term   :       "FullDuplexSerial.spin"
  serialTerminal  :       "Parallax Serial Terminal.spin"

Pub Main | capturedValue

  serialTerminal.Start(38_400)
  term.start(0, 2, 0, 38_400)

  term.hex($56002600, 8)
  capturedValue := term.rxtime(100)
  capturedValue := (capturedValue << 8 ) + term.rx
  capturedValue := (capturedValue << 8 ) + term.rx
  capturedValue := (capturedValue << 8 ) + term.rx

  term.stop

  repeat
    waitcnt(50_000_000 + cnt)
    serialTerminal.Str(string("Hex test "))
    serialTerminal.Hex(capturedValue,8)
    serialTerminal.NewLine
  while (1)

Comments

  • kuronekokuroneko Posts: 3,623
    edited 2012-03-09 18:05
    What's the camera expecting, bytes (4) or the ASCII representation of said bytes (8)? Currently you send 8 bytes which usually isn't the right thing to do. Try:
    value := $56002600
      repeat 4
        term.tx(value)
        value >>= 8
    
      value := $56002600
      repeat 4
        value <-= 8
        term.tx(value)
    
    The first example sends $00 first, the second $56.
  • pattywacpattywac Posts: 22
    edited 2012-03-10 11:49
    kuroneko,
    Neither of those options seemed to work, which led me to believe that my wiring was incorrect. I checked it over 10-15 times and it seemed perfect, so I broke my multimeter and started testing voltages. For some strange reason my powersupply was only putting out approximately 3.6volts. In various forums I read that this specific camera doesn't like anything below 5v. I fixed the PS issue and went back to the code.... still didn't work. I cleaned it up a bunch and tried to test the 'tx' code even more and found a combination that works:
    Con
    
      _clkmode = xtal1 + pll16x
      _xinfreq = 5_000_000
    
    OBJ
      serialCamera    :       "FullDuplexSerial.spin"
      serialTerminal  :       "Parallax Serial Terminal.spin"
    
    Pub Main | capturedValue, value
      waitcnt(250_000_000 + cnt)
      serialTerminal.Start(38_400)
      serialCamera.start(0, 2, 0, 38_400)
    
      repeat
        waitcnt(50_000_000 + cnt)
        serialTerminal.NewLine
        serialTerminal.Str(string("Attempting to send again... "))
        serialTerminal.NewLine
        serialCamera.rxflush
    
        serialCamera.tx($56)
        serialCamera.tx($00)
        serialCamera.tx($26)
        serialCamera.tx($00)
    
        capturedValue := serialCamera.rxtime(1000)
        capturedValue := (capturedValue << 8 ) + serialCamera.rx
        capturedValue := (capturedValue << 8 ) + serialCamera.rx
        capturedValue := (capturedValue << 8 ) + serialCamera.rx
    
        serialTerminal.Str(string("Hex value: "))
        serialTerminal.Hex(capturedValue,8)
        serialTerminal.NewLine
        serialTerminal.Str(string("In Dec: "))
        serialTerminal.Dec(capturedValue)
        serialTerminal.NewLine
      while (1)
    

    It seems strange that your code didn't work because from what I can tell, it should be doing the same thing as the four consecutive 'tx' calls. For now I'm happy, I got back the right hex code in response from the camera module (76002600).

    Now that I look at it, shouldn't your second option (starting with $56) be:
      value := $56002600
      repeat 4
        term.tx(value)
        value <-= 8
    
  • kuronekokuroneko Posts: 3,623
    edited 2012-03-10 16:03
    The tx method sends the LSB of the parameter. So if you send-before-rotate the first byte will be $00 followed by $56, $00 and $26. That said, what happens if you put a dummy delay between your tx calls, e.g. a result <-= 0? I wonder if it is a timing issue (too much delay between characters).

    Edit: I just did some quick checks and this doesn't really add up. The loop version takes 22320 cycles to get the 4 bytes into the serial object. At this speed (38400) this is still (nearly) covered by the time it takes to send the first character (20833 cycles). So it's unlikely to be between-character-delays. But people here have brought up really weird timing issues before so who knows.

    Out of curiosity, what's the response you get from the camera when you use the loop version (rotate-before-send)? It may be useful to print each byte as you receive it.
  • pattywacpattywac Posts: 22
    edited 2012-03-10 19:51
    Tried to print each value and I just get $FF every time. I think (and i could be completely wrong) that means the prop isn't receiving any info. The camera module only has 8 or 9 recognized hex commands, so hardcoding multiple .tx's won't take more than a few minutes.

    Here's the data sheet:
    http://www.sparkfun.com/datasheets/Sensors/Imaging/1274419957.pdf
Sign In or Register to comment.