Shop OBEX P1 Docs P2 Docs Learn Events
Sending a 12-bit value with Serial Mirror.sping (bytewise / 8-bit) — Parallax Forums

Sending a 12-bit value with Serial Mirror.sping (bytewise / 8-bit)

propwellpropwell Posts: 87
edited 2010-01-19 15:48 in Propeller 1
Hi folks,

i've got the MCP3208 ADC running on my Propeller. Problem: it is a 12-bit ADC and, as far as i know, the serial interface communicates with 8-bit-blocks?!? So the highest number i can send is a 255, wherelse the maximum of 12 bit is 4096 isn't it? Can you help me therefor?

Thank you very much,
Max

Comments

  • JonnyMacJonnyMac Posts: 9,208
    edited 2010-01-18 22:08
    Not a problem: send two bytes. Most would send the low byte, then the high byte, but your equipment may want the other way. In Spin you might do something like this:

    value := READ_ADC(channel)
    term.tx(value.byte[noparse][[/noparse] 0 ])
    term.tx(value.byte[noparse][[/noparse] 1 ])
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon McPhalen
    Hollywood, CA
  • propwellpropwell Posts: 87
    edited 2010-01-19 11:58
    Hi JonnyMac,

    sounds good! So on the PC-side, i can recalculate it with byte[noparse][[/noparse]0]+256*byte?

    Greetz and thank you very much!

    Post Edited (propwell) : 1/19/2010 1:10:26 PM GMT

  • JonnyMacJonnyMac Posts: 9,208
    edited 2010-01-19 15:48
    Exactly. Easy-peezy.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon McPhalen
    Hollywood, CA
Sign In or Register to comment.