Shop OBEX P1 Docs P2 Docs Learn Events
HEX to binary — Parallax Forums

HEX to binary

dosmithdosmith Posts: 15
edited 2006-07-03 18:35 in BASIC Stamp
I'm trying to program to the serial port of a Kramer VP-23 switcher. The manual indicates that is uses four bytes of information at 9600, no parity, 8 data bits and 1 stop bit. The code I'm trying to send (according to the manual is : 01, 82, 83, 81. What does the format of the SEROUT command on pin 7 look like? I'm told from the manufacturer that the box only understands binary. Thanks.

Comments

  • PJAllenPJAllen Banned Posts: 5,065
    edited 2006-06-16 13:15
    It gets sent out binary; the start bit, the data bits (8), and then the stop bit -- serially, each in succession.· But via Pin7 it's logic level, not RS-232.
  • dosmithdosmith Posts: 15
    edited 2006-06-16 13:28
    Assume that I only know enough to be very dangerous. Can you tell me what the command would look like to send the command 01 82 82 81? thanks.
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2006-06-16 13:52
    One thing is, I think that you do not want to connect your Kramer-device directly to pin7.·

    Which STAMP are you using (it's relevant)?
  • dosmithdosmith Posts: 15
    edited 2006-06-16 14:04
    BS2. Thanks.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-06-16 14:04
    Hello,

    ·· The Editor Help File shows the syntax and examples of using the SEROUT command.· Essentially it would be:

    SEROUT DPin, Baud, [noparse][[/noparse]01, 82, 83, 81]

    If the device normally plugs into a computer and is RS-232 level then you may not be able to send directly to it from an I/O pin.· If you are the baud rate may need to be inverted.·

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • dosmithdosmith Posts: 15
    edited 2006-06-16 18:43
    Still not getting anywhere. We've used this setup in the past so I know it works. I've got a tester setup to see that the data is passing to the box. The code I'm using is:
    SEROUT 7,16468[noparse][[/noparse]01,81,83,81]. I've also tried using 84 for the baud settings. Someone also suggested the need for a CR in order for this to work. Thanks for any additional input.
  • dosmithdosmith Posts: 15
    edited 2006-06-16 18:55
    I've got a unit already working for this purpose but the person who did the orginal code left and didn't archive it. Is there any way to pull the code off a processor already in production? thanks.
  • FranklinFranklin Posts: 4,747
    edited 2006-06-16 19:01
    According to the specs I could find it is talking RS-232 which is NOT what the stamp is talking. Listen to the people that are telling you that you need a level converter between these devices.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2006-06-16 19:02
    Nope, you can't get it back (it's a feature, it keeps 3rd parties from glomming your program.)· You could plug it into·a Terminal program (one that will show HEX, not HyperTerm) on your PC·and maybe that way find out what it's actually transmitting.
  • dosmithdosmith Posts: 15
    edited 2006-06-16 19:22
    I appreciate Stephen's comments but that doesn't explain how I can have a unit doing exactly what I'm describing. Thanks.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-06-16 19:30
    The unit that is working...How is it connected?· From what pins on the BS2 to what on the target device?· Going through any sort of driver or converter?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • dosmithdosmith Posts: 15
    edited 2006-06-16 20:16
    Conected on I/O 7 to pin 2 on the serialport of the kramer.
  • SSteveSSteve Posts: 808
    edited 2006-06-16 20:22
    The title of the thread is "HEX to Binary". Are the values 01, 82, 83, 81 hex values? If so, your statement should be SEROUT DPin, Baud, [noparse][[/noparse]$01, $82, $83, $81].

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    OS-X: because making Unix user-friendly was easier than debugging Windows

    links:
    My band's website
    Our album on the iTunes Music Store
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2006-06-16 20:25
    The numeros in stated in the posts are inconsistent.
  • SSteveSSteve Posts: 808
    edited 2006-06-16 20:28
    PJ Allen said...
    The numeros in stated in the posts are inconsistent.
    They sure are. I hadn't noticed that. One can only hope he's being more careful in his code than in his posts. wink.gif

    In any case, if the values in the documentation are hex, they should be prefixed with a '$' in the code.

    Edit: I just downloaded the VP-23 manual and they are indeed hex, so the '$' is necessary.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    OS-X: because making Unix user-friendly was easier than debugging Windows

    links:
    My band's website
    Our album on the iTunes Music Store

    Post Edited (SSteve) : 6/16/2006 8:32:32 PM GMT
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-06-17 01:27
    Steve,

    ·· Is the manual in a PDF format you can post, or perhaps provide a link?· If I had·it, I too could offer better assistance.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • FranklinFranklin Posts: 4,747
    edited 2006-06-17 03:47
    http://catalogs.infocommiq.com/AVCAT/images/documents/pdfs/VP-23_User Manual.pdf

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-06-17 03:58
    Franklin,

    ·· Thanks...Interesting...It looks pricey!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • dosmithdosmith Posts: 15
    edited 2006-06-22 18:00
    Thanks for all the input. I'm still not getting any response from the Kramer. I've attached the code. As I mentioned in an earlier post I'm a rookie and know enough to be dangerous. Any and all help is greatly appreciated.
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2006-06-23 00:05
    There's stuff that SEROUTs on 0·(which would be the programming connector of an HWB or a BoE)·and other stuff that SEROUTs on P7, the numbers SEROUT of P7.·

    So, is P7 connected to an RS232 converter or what?
    ·
    And what is it that the programming connector is connected to?

    Is the program connector connected to this Kramer-thing?

    I would like to see a diagram of the set-up/s.
  • bennettdanbennettdan Posts: 614
    edited 2006-06-23 02:32
    If the unit only understands Hex and the chart is in Hex to send comands are you suppose to convert them to binary before you send them?
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2006-06-23 03:18
    Well, in a word, No.· If you send $FF (or DEC 255), the data bits that it sends out will be 1111 1111, it doesn't send an "F" and and "F".· That's what the 8-bits in 8-N-1 is all about (it's a byte.)
  • bennettdanbennettdan Posts: 614
    edited 2006-06-23 03:52
    I see so the stamp converts it internaly due to port settings?
  • SSteveSSteve Posts: 808
    edited 2006-06-23 03:55
    The baud rates in the SEROUT commands aren't consistent. Some are 16468 and some are 16568. You can eliminate that type of error by using a constant for your baud rate. That would also make it a lot easier to try a baud rate of 84 as a test.

    Your comments should also specify what pins 1-7 connected to. It would make it a lot easier for others (read: the people trying to help you on this forum wink.gif) to figure out the code.

    CLOOP = 1
      FOR CLOOP = 1 TO 75
      TOGGLE 1
      PAUSE 500
      CLOOP = CLOOP + 1
      NEXT
    


    That's almost guaranteed to not do what you want. You shouldn't be modifying the index variable inside a FOR/NEXT loop unless you're doing it for a very specific reason. You probably meant this:
      FOR CLOOP = 1 TO 75
      TOGGLE 1
      PAUSE 500
      NEXT
    


    Note that I removed the unneeded CLOOP = 1 statement before the loop.

    It's hard to guess what else might be causing the problem. Maybe you should try a simpler program just to see if you're communicating at all.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    OS-X: because making Unix user-friendly was easier than debugging Windows

    links:
    My band's website
    Our album on the iTunes Music Store
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-06-23 14:15
    bennettdan said...
    I see so the stamp converts it internaly due to port settings?
    Hello,

    ·· No, there are no conversions being done.· A microcontroller can only understand binary.· While the Stamp Editor will allow you to refer to values in DEC or HEX or BINARY the data is always in binary form in the memory, no matter what.· It's how you choose to display it that affects it.· So when it's sent out it's in its native form without conversion.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • dosmithdosmith Posts: 15
    edited 2006-07-03 13:19
    thanks for the info. I still think it's a formatting issue with the command. On page 10 of the manual (http://catalogs.infocommiq.com/AVCAT/images/documents/pdfs/VP-23_User Manual.pdf) it indicates binary code. On page 11 it lists the commands that need to be sent and shows them as decimal. If I want to send the command 81 83 81 01 to switch to the first input of the vga group, what should the code look like for the SEROUT command on pin 7? thanks.
  • SSteveSSteve Posts: 808
    edited 2006-07-03 14:01
    SEROUT 7, baudrate, [noparse][[/noparse]$81, $83, $81, $01]

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    OS-X: because making Unix user-friendly was easier than debugging Windows

    links:
    My band's website
    Our album on the iTunes Music Store
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-07-03 18:35
    Steve's code looks correct...Once you posted the datasheet you could see from the table that the values are HEX, not Decimal...There is a difference, since 80 decimal and $80 (Hex) are not the same thing.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
Sign In or Register to comment.