HP Forums
HP50g serial communication with 3rd party device - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: General Forum (/forum-4.html)
+--- Thread: HP50g serial communication with 3rd party device (/thread-4416.html)



HP50g serial communication with 3rd party device - Marakasmalan - 07-23-2015 10:40 PM

Apologies, this thread was by mistake first posted in the Articles Forum - I reported to mods to have it moved. Sorry!

Hello Folks,

Firstly, thanks for maintaining this site and the forum.

Secondly, I tried to research as much as possible within my comprehension prior to posting this question.

Some of the advice on similar threads seems to be above my uneducated mind, but I am on the right track I believe. Some clarification would however be appreciated.

I am trying to communicate via RS-232 port with a 3rd party device. Though the end goal is somewhat more complicated, the first step is to send an instruction or a command, to which the device will send a reply.

Now, the instructions from the 3rd party device is as follows:

"All communication should be done at a rate of 115200 bps with 8 data bits, 1 stop bit and no parity bits.
No flow control should be performed.

All commands sent to the device and responses sent back have the following basic format:
<Prefix > . <Variable> <Operator> <Value> <CR> (and/or) <LF>"

This means some obvious settings for the IOPAR list which makes sense, except the protocol. And the hpcalc.org cable, which I have.

First question:
What protocol is used here, as Xmodem or Kermit is not specified?

Should I instead make use of a program such as dterm or terminaltor 0.45 (which I am slightly carefull because of the ML programming being more unintelligable to me than the dterm source code, the latter of which I can make some sense)

Or can I simply program instructions such as:

<< "<Prefix > . <Variable> <Operator> <Value>" 13 CHR + XSEND >>

How will the calculator know it is suppose to receive after sending the command?

Before I start programming a list off different commands, I first want to establish the frimware version of the device, the command should be as follows:

Description: Query Firmware Version
Example: <CR>Main.Version?<CR>

Any advice in this regard would be greatly appreciated.

Thanks a lot

Marakasmalan


RE: HP50g serial communication with 3rd party device - snrowe - 07-24-2015 03:36 AM

Hi,

Think the commands you may be looking for are:
XMIT (Requires a string to be sent to serial device on line 1 of stack. Will return 1 or 0)
BUFLEN (Requires nothing on stack. Will return 1 or 0, if 1 will have the length of the buffer on line 2 of stack)
SRECV (Requires length of expected reply on line 1 of stack, will return 1 or 0, if 1 the response string will be on line 2 of stack)

To send a command and then listen for a response you'd try something like:

<< "<Prefix > . <Variable> <Operator> <Value> <CR> (and/or) <LF>"
XMIT DROP 1 WAIT BUFLEN DROP 1 WAIT SRECV >>

You may want to increase the wait time or eliminate it all together depending on how fast your serial device can process commands.


RE: HP50g serial communication with 3rd party device - Marakasmalan - 07-24-2015 03:58 AM

Wow, Thanks!


<< "<Prefix > . <Variable> <Operator> <Value> <CR> (and/or) <LF>"
XMIT DROP 1 WAIT BUFLEN DROP 1 WAIT SRECV >>

13 CHR will give me a carriage return?

Kermit or Xmodem protocol irrelivant?

I will try it and let you know!

Regards


RE: HP50g serial communication with 3rd party device - snrowe - 07-24-2015 04:12 AM

(07-24-2015 03:58 AM)Marakasmalan Wrote:  Wow, Thanks!


<< "<Prefix > . <Variable> <Operator> <Value> <CR> (and/or) <LF>"
XMIT DROP 1 WAIT BUFLEN DROP 1 WAIT SRECV >>

13 CHR will give me a carriage return?
-YES that should work

Kermit or Xmodem protocol irrelivant?
-Yes these commands are specific for serial communication. Another useful command is STIME which sets the time that SRECV will wait for a response before giving up.

I will try it and let you know!
-FYI I've used the HPcalc.org serial cable with limited success sometimes I get dropped characters or garbage in responses. I don't have these same issues when using an hp48SX, GX or HP49G and their serial cables. Good luck let us know if it works

Regards



RE: HP50g serial communication with 3rd party device - Marakasmalan - 07-26-2015 12:28 PM

OK, so I tried it, but no success really.

After each command (SMIT, SRECV, BUFLEN), it returns a "1" - does that indicate an error occurred or does that indicate success?

The return information is not the same after repeating the same command to the device, and furthermore it is "garbage", unintelligable an sometimes up to three characters of sensible information.

What I do not know is what Xlat need to be set to, though I played around with different settings and also dit try different values for wait, from one up to seven.

Unfortunately I do not have a 48 that I could try the same with.

ANy ideas?


RE: HP50g serial communication with 3rd party device - Marakasmalan - 07-26-2015 12:30 PM

And I used fresh batteries!


RE: HP50g serial communication with 3rd party device - snrowe - 07-26-2015 02:44 PM

(07-26-2015 12:28 PM)Marakasmalan Wrote:  OK, so I tried it, but no success really.

After each command (SMIT, SRECV, BUFLEN), it returns a "1" - does that indicate an error occurred or does that indicate success?

The return information is not the same after repeating the same command to the device, and furthermore it is "garbage", unintelligable an sometimes up to three characters of sensible information.

What I do not know is what Xlat need to be set to, though I played around with different settings and also dit try different values for wait, from one up to seven.

Unfortunately I do not have a 48 that I could try the same with.

ANy ideas?

What are you communicating with? Are you sure the signal from the device is at the correct voltage levels for RS232? Did you try removing the wait command? Instead of using BUFLEN you may want to directly enter in the number of characters expected in the response (see below)

<<
BUFLEN DROP SRECV DROP2 @Clears Buffer of any old data
"Command" XMIT DROP @Sends "Command" string to serial device
10 SRECV DROP @Receives data via serial until 10 characters are received or STIME has elapsed with no response, adjust the number 10 to correspond the expected length of the response from the serial device.
>>

Think you meant XMIT not SMIT. 1 indicates success, but with XMIT this means only that the calculator successfully sent the command doesn't indicate it was successfully received by the other device.

BUFLEN returns the number of characters in the HP48 IO Buffer so this may not correspond to your expected response length if the entire response doesn't fit in the buffer or hasn't been fully sent yet.

You should also turn off the clock display. The ticking clock may interrupt the transfer and corrupt data.

If none of this works you may want to verify whether you can control the device via HyperTerminal or some other program to make sure the problem isn't on the device end.

Good luck let us know how it goes


RE: HP50g serial communication with 3rd party device - Marakasmalan - 07-26-2015 08:58 PM

@snrowe: THANKS

OK, I will try these suggestions. Where can I find exactly wat the three different "Xlat" (I presume ASCII translation codes) does/imply?

The device is a nad T748 avr amplifier receiver.

I will try the Hyperterminal and see how that work, however at the moment I only have my work laptop (on which I cannot install anything) that does not have a serial port, so I will get a USB - Serial converter before I can do that.

Our brilliant goverment believes it does not ned to heed to advice, and consequently we now do not have enough power for the country. When the grid is overloaded, they impose "loadshedding", disconnecting areas off the grid on a predetermined roster. But when they switch it on again, the supply voltage is all over the show and it blew up my motherboard and power supply from my personal computer. Need to fix come next payday.

Some interesting observations:

Switching the device on and trying bufleng gives 0 and 1. Same happens when I try to clear the buffer as indicated in previous post.

After sending a command, it does find something in the buffer. So something did come back. However, the avr did not execute the command that was sent to it.

What would have been the result if the pins on the serial cord was the wrong way round?

Regards and thanks a lot!


RE: HP50g serial communication with 3rd party device - Marakasmalan - 07-26-2015 10:12 PM

I also tried to use LF (10CHR) instead, no difference.

"All communication should be done at a rate of 115200 bps with 8 data bits, 1 stop bit and no parity bits.
No flow control should be performed."

MY IOPAR variable is set to { 115200. 0. 0. 0. 1. 3. }

I also note the device RS232 instructions specify:

"RS-232 port and use the newer RS232 protocol V2.X. The new protocol, V2.X, is all ASCII based, with the goal of making it easier to use."

Will this protocol V2.X be compatible with the calculator?


RE: HP50g serial communication with 3rd party device - snrowe - 07-26-2015 10:55 PM

(07-26-2015 08:58 PM)Marakasmalan Wrote:  @snrowe: THANKS

OK, I will try these suggestions. Where can I find exactly wat the three different "Xlat" (I presume ASCII translation codes) does/imply?

I was under the impression Xlat refers to ASCII transfers, but I am not 100% sure. In any case I would try "None" for Xlat unless you know you want to translate characters. Not exactly sure on this one, suppose you could connect HyperTerminal and see what the HP50G sends with the different Xlat settings.

(07-26-2015 08:58 PM)Marakasmalan Wrote:  The device is a nad T748 avr amplifier receiver.

I will try the Hyperterminal and see how that work, however at the moment I only have my work laptop (on which I cannot install anything) that does not have a serial port, so I will get a USB - Serial converter before I can do that.
I've had limited success with the cheap USB to serial converters. You also may run into driver issues if you go that route.

I choose to use a serial to Bluetooth dongle to connect to modern devices. It's a bit pricey but works well and you can connect your hp50G wirelessly!
Aircable has some products for this. I use the aircable mini
Note you have to solder wire to power pin 9.
This particular BT dongle is very low power and will operate quite a while off a lithium ion battery.

(07-26-2015 08:58 PM)Marakasmalan Wrote:  Our brilliant goverment believes it does not ned to heed to advice, and consequently we now do not have enough power for the country. When the grid is overloaded, they impose "loadshedding", disconnecting areas off the grid on a predetermined roster. But when they switch it on again, the supply voltage is all over the show and it blew up my motherboard and power supply from my personal computer. Need to fix come next payday.

Where abouts are you located. Sounds like a big pain in the @!#$.

(07-26-2015 08:58 PM)Marakasmalan Wrote:  Some interesting observations:

Switching the device on and trying bufleng gives 0 and 1. Same happens when I try to clear the buffer as indicated in previous post.

OK I think I found the source of problems with the HP50g vs the HP48 when using this code. The HP50g has some issues using BUFLEN that the HP48 doesn't. Remove BUFLEN and use below:

<<

.5 STIME @sets timeout for SRECV adjust per your needs
"Command" XMIT DROP @Sends command to AVR
10 SRECV DROP @Adjust 10 to the number of characters you expect. If you don't know how many set it to the maximum number of characters for the response. If the response is less it will wait STIME return 0, but the response will be above.
>>

Uncommented below:
<<
.5 STIME
"Command" XMIT DROP
10 SRECV DROP
>>

(07-26-2015 08:58 PM)Marakasmalan Wrote:  After sending a command, it does find something in the buffer. So something did come back. However, the avr did not execute the command that was sent to it.

What would have been the result if the pins on the serial cord was the wrong way round?

Incorrect wiring of pin 2 and 3 could be the issue. You may need a null modem to swap transmit and receive.

Sounds like a fun project. Hope some of this was helpful and you get it working.

FYI if you use a HP48G you might be able to use REMOTEBG to control this device via IR. I used to use an alarm to turn my HP48GX on and then my receiver on and play certain songs for my alarm clock in college.


RE: HP50g serial communication with 3rd party device - snrowe - 07-26-2015 11:03 PM

(07-26-2015 10:12 PM)Marakasmalan Wrote:  I also tried to use LF (10CHR) instead, no difference.

"All communication should be done at a rate of 115200 bps with 8 data bits, 1 stop bit and no parity bits.
No flow control should be performed."

MY IOPAR variable is set to { 115200. 0. 0. 0. 1. 3. }

I also note the device RS232 instructions specify:

"RS-232 port and use the newer RS232 protocol V2.X. The new protocol, V2.X, is all ASCII based, with the goal of making it easier to use."

Will this protocol V2.X be compatible with the calculator?

Try adjusting your IOPAR to {115200. 0. 0. 0. 1. 0.} so Xlat is none.
I don't know about the V2.X. protocol so I can't help you there.


RE: HP50g serial communication with 3rd party device - Marakasmalan - 07-27-2015 01:27 AM

(07-26-2015 10:55 PM)snrowe Wrote:  Where abouts are you located. Sounds like a big pain in the @!#$.
South Africa. Heading the same route as Zimbabwe it seems.

I'll have a look and try your suggestions.

(07-26-2015 10:55 PM)snrowe Wrote:  I've had limited success with the cheap USB to serial converters. You also may run into driver issues if you go that route.

The pcie IO cards are actually cheaper than the converters. Most laptop docking stations still have a serial port as well. The Blutooth solution looks very interesting, I will try that route!

Thanks, once again


RE: HP50g serial communication with 3rd party device - Marakasmalan - 07-27-2015 10:30 AM

Think I got the problem:

From the device's manual:
"Pin Function
• 2 Transmit Data
• 3 Receive Data
• 5 Signal Ground

This pinout allows the NAD product to be connected to a PC with a standard straight throw serial cable."

To connect the hpcalc.org serial cable to a pc, a null modem adaptor is required. I will aquire this today and try again!

Thank you for all the help


RE: HP50g serial communication with 3rd party device - Marakasmalan - 08-03-2015 07:35 AM

Just an update:

Ok, so after all the help I tried various things:

Using the null modem adaptor did not fix anything, but what I did notice is that when connected to the device (straight or with null modem), garbage returns to the buffer. If not connected the buffer remains clear. Also, copied HyperTerminal to Win 7 (need the exe file and some .dll files, but a simple copy) and did not establish success when communicating to Hyperterminal.

I will now try two things:

1. Use a different calculator
2. Check what will happen if I connect via HT to the device.

It seems the Serial port of the 50g is not functioning correctly, especially given the inability to communicate with the PC via serial. Thus far only tested on the serial port of the laptop's docking station.

Regards


RE: HP50g serial communication with 3rd party device - RMollov - 08-03-2015 07:44 AM

(08-03-2015 07:35 AM)Marakasmalan Wrote:  Just an update:

Ok, so after all the help I tried various things:

Using the null modem adaptor did not fix anything, but what I did notice is that when connected to the device (straight or with null modem), garbage returns to the buffer. If not connected the buffer remains clear. Also, copied HyperTerminal to Win 7 (need the exe file and some .dll files, but a simple copy) and did not establish success when communicating to Hyperterminal.

I will now try two things:

1. Use a different calculator
2. Check what will happen if I connect via HT to the device.

It seems the Serial port of the 50g is not functioning correctly, especially given the inability to communicate with the PC via serial. Thus far only tested on the serial port of the laptop's docking station.

Regards

I wasn't able to make working serial connection to hp50 with surveying total stations and gave up. Unlike the hp48 series which all worked flawlessly.


RE: HP50g serial communication with 3rd party device - snrowe - 08-04-2015 02:29 AM

(08-03-2015 07:35 AM)Marakasmalan Wrote:  Just an update:

Ok, so after all the help I tried various things:

Using the null modem adaptor did not fix anything, but what I did notice is that when connected to the device (straight or with null modem), garbage returns to the buffer. If not connected the buffer remains clear. Also, copied HyperTerminal to Win 7 (need the exe file and some .dll files, but a simple copy) and did not establish success when communicating to Hyperterminal.

I will now try two things:

1. Use a different calculator
2. Check what will happen if I connect via HT to the device.

It seems the Serial port of the 50g is not functioning correctly, especially given the inability to communicate with the PC via serial. Thus far only tested on the serial port of the laptop's docking station.

Regards

Did you try leaving the BUFLEN command out?
<< 1 STIME 10 SRECV >>
If I use the BUFLEN command while the HP50G is receiving I often get garbage.
I've used HyperTerminal many times with HP50G XMODEM, but not with serial commands. I will try later and see if it works for me.


RE: HP50g serial communication with 3rd party device - snrowe - 08-04-2015 03:13 AM

(08-04-2015 02:29 AM)snrowe Wrote:  
(08-03-2015 07:35 AM)Marakasmalan Wrote:  Just an update:

Ok, so after all the help I tried various things:

Using the null modem adaptor did not fix anything, but what I did notice is that when connected to the device (straight or with null modem), garbage returns to the buffer. If not connected the buffer remains clear. Also, copied HyperTerminal to Win 7 (need the exe file and some .dll files, but a simple copy) and did not establish success when communicating to Hyperterminal.

I will now try two things:

1. Use a different calculator
2. Check what will happen if I connect via HT to the device.

It seems the Serial port of the 50g is not functioning correctly, especially given the inability to communicate with the PC via serial. Thus far only tested on the serial port of the laptop's docking station.

Regards

Did you try leaving the BUFLEN command out?
<< 1 STIME 10 SRECV >>
If I use the BUFLEN command while the HP50G is receiving I often get garbage.
I've used HyperTerminal many times with HP50G XMODEM, but not with serial commands. I will try later and see if it works for me.

I tried serial commands with HyperTerminal on windows8 and got something on the screen but it was not the text string. Appears the HP50G can send to HyperTerminal fine with the HPcalc cable. I got the same results with a HP48SX. Make sure all your settings are right baud etc.... Xmodem works fine with both calculators and HyperTerminal.


RE: HP50g serial communication with 3rd party device - TomC - 08-08-2015 10:43 AM

Hello:

Sorry it has taken a while to respond.

It has been found that the 'RS232' port of the HP50G is not quite right and a special cable is required for the HP50g to communicate with standard RS232 devices.

You can purchase one here:

http://commerce.hpcalc.org/serialcable.php

Hope this helps!
TomC


RE: HP50g serial communication with 3rd party device - Tugdual - 08-08-2015 11:20 AM

Interesting thread, didn't know there were RS232 commands.
So theoretically one could flash a 34s with a 50G? Smile