Post Reply 
The ultimate partner for the HP Prime G2 - The Arduino Leonardo.
05-17-2023, 06:11 PM
Post: #1
The ultimate partner for the HP Prime G2 - The Arduino Leonardo.
The HP Prime can connect directly to an Arduino Leonardo (which can speak USB HID). This allows input from any type of sensor you can think of, or output to any type of device, such as a piezo speaker for a BEEPER for example. You can log any data on the Prime, display it as a graph or process it, or you could use the HP Prime as an input into Arduino projects with all of its great buttons and multitouch screen.

Here is a short video of the connection to an Arduino Leonardo which has an LDR attached to it.



This is very easy to use, requires no software setup and allows any analog sensor or digital communication protocol to be sent to Arduino and output to HP Prime.

USBOpen(9025,32822) opens the connection to the Arduino, after that you send data from the Arduino or to the Arduino, receiving that data is as simple as USBRecv. The numbers sent from Arduino will appear in a list (64 bytes). If you use USBSend({1,2,3,4}), then the Arduino receives 1,2,3,4. It really couldn't be any simpler.

It is now possible to connect anything you want to your HP Prime G2 through the Arduino.
Find all posts by this user
Quote this message in a reply
05-17-2023, 06:47 PM
Post: #2
RE: The ultimate partner for the HP Prime G2 - The Arduino Leonardo.
Very nice.

I like that you got a USB keyboard hooked up to your Prime in another video. The HobbyTronics USB Host Controller Board looks to most excellent and well priced too.
Find all posts by this user
Quote this message in a reply
05-17-2023, 07:06 PM
Post: #3
RE: The ultimate partner for the HP Prime G2 - The Arduino Leonardo.
(05-17-2023 06:47 PM)jonmoore Wrote:  Very nice.

I like that you got a USB keyboard hooked up to your Prime in another video. The HobbyTronics USB Host Controller Board looks to most excellent and well priced too.

I have found out since making that, that you can just plug a keyboard directly into the HP Prime with an OTG cable. It will be visible with USBOpen(), entering that will give the connection details, then the next time you use the details it gave you USBOpen(8425,43288) e.g. will connect it. Then USBRecv() will get the keyboards method of displaying the different keys.
Find all posts by this user
Quote this message in a reply
05-17-2023, 08:04 PM
Post: #4
RE: The ultimate partner for the HP Prime G2 - The Arduino Leonardo.
(05-17-2023 07:06 PM)matalog Wrote:  
(05-17-2023 06:47 PM)jonmoore Wrote:  Very nice.

I like that you got a USB keyboard hooked up to your Prime in another video. The HobbyTronics USB Host Controller Board looks to most excellent and well priced too.

I have found out since making that, that you can just plug a keyboard directly into the HP Prime with an OTG cable. It will be visible with USBOpen(), entering that will give the connection details, then the next time you use the details it gave you USBOpen(8425,43288) e.g. will connect it. Then USBRecv() will get the keyboards method of displaying the different keys.

Even better. Smile

Ref the Arduino Leonardo, I always though that MicroPython would open the doors to some interesting DIY calculator IO options. It's great to see a low cost DIY option that could easily form the basis of school/college curriculum shenanigans without the usual expense of the TI ecosystem.
Find all posts by this user
Quote this message in a reply
05-17-2023, 11:29 PM
Post: #5
RE: The ultimate partner for the HP Prime G2 - The Arduino Leonardo.
Nice, thanks for the info. But apart from the Leonardo being able to connect to kb &/or mouse, is there any advantage over using an older Arduino. e.g. I still have a Duemilanove which I got when it first came out. Haven't used it in a long time, so I should probably dust it off.
Find all posts by this user
Quote this message in a reply
05-17-2023, 11:44 PM
Post: #6
RE: The ultimate partner for the HP Prime G2 - The Arduino Leonardo.
(05-17-2023 11:29 PM)8031Brown Wrote:  Nice, thanks for the info. But apart from the Leonardo being able to connect to kb &/or mouse, is there any advantage over using an older Arduino. e.g. I still have a Duemilanove which I got when it first came out. Haven't used it in a long time, so I should probably dust it off.

Only a Leonardo (or a (Pro)Micro)) will work natively with the Prime like this, they have proper USB connectivity and can talk HID language correctly.

You might actually be able to completely change the programming of an UNO or the like, but it is a much bigger job to anyone not versed in such and may not allow all other things to be connected, it will involve putting HoodLoader2 on the device and that itself may limit other serial connectivity, I'm not certain.
Find all posts by this user
Quote this message in a reply
05-18-2023, 08:50 AM
Post: #7
RE: The ultimate partner for the HP Prime G2 - The Arduino Leonardo.
Excellent work! A few questions for you:
  1. Can you use the FT260 with the same HP Prime code (other than changing the device id)?
  2. What is the light sensor that you used?
  3. It looks like you have a potentiometer attached as well, is that for another input?
  4. Can you publish your source code and wiring sketch so that we can have a look and adapt it for other sensors?
  5. Did you have to do anything to the Leonardo other than plug it in?
It would be great if we could build a library of sensor interfaces and real-time graphing routines. I'm still trying to figure out why the BME680 sensor is giving odd results on the Prime, but works perfectly on a Raspberry Pi.
Find all posts by this user
Quote this message in a reply
05-18-2023, 11:17 AM
Post: #8
RE: The ultimate partner for the HP Prime G2 - The Arduino Leonardo.
(05-18-2023 08:50 AM)Mark Power Wrote:  Excellent work! A few questions for you:
  1. Can you use the FT260 with the same HP Prime code (other than changing the device id)?
  2. What is the light sensor that you used?
  3. It looks like you have a potentiometer attached as well, is that for another input?
  4. Can you publish your source code and wiring sketch so that we can have a look and adapt it for other sensors?
  5. Did you have to do anything to the Leonardo other than plug it in?
It would be great if we could build a library of sensor interfaces and real-time graphing routines. I'm still trying to figure out why the BME680 sensor is giving odd results on the Prime, but works perfectly on a Raspberry Pi.

The code for using the FT260 is very similar but not the same. The FT260 needs to communicate with a code first, to define the type of communication, then a byte mentioning the length of data. While I could instruct the Arduino to send those bytes, I kept the program as simple as possible and only sent one byte at a time with the direct connection to Arduino Leonardo - resulting in a smoother graph. Using the Leonardo allows RAW HID bytes to be sent, you can just send relevant data numbers, or you could add a send marker and length data if you want.

The light sensor is just an LDR I had lying around, it is a resistor whose value is changed when light hits it. The reason that the potentiometer is there is to 'tune' the LDR to range the voltage it outputs somewhere between 0v and 5v so that the full range of light my torch can supply, covers the full range of the graph, it along with the LDR are acting as a voltage divider.

I certainly will post the code. I'm at work now, and will post it this evening.

The Leonardo has to have a program on it to run which needs the Arduino-HID Project library to become a recognisable HID device, just include that in the Arduino Program, and a few lines from the RAW-HID example depending on if you want to get data into the calculator or send data out of the calculator.
Find all posts by this user
Quote this message in a reply
05-18-2023, 02:03 PM
Post: #9
RE: The ultimate partner for the HP Prime G2 - The Arduino Leonardo.
The ATmega32U4 (watch for the 'U') in the Leornardo micro/pro family supports the USB-HID with its build-in USB controller as matalog shows.

Matalog's current solution provides a simple method to send/receive raw USB HID data (like a keyboard or a mouse) with some additional Arduino USB-HID coding (in addition to the HP Prime programming) to/from a single sensor/port.

The FT260 requires a command opcode/data length in its protocol to address multiple devices at once, as well as header overhead reduction (speed) (i.e. multiple sensors/sound generators/modems on the I2C bus, or serial data vs interrupt differentiation). That makes the FT260 protocol a bit more complex.

The Micro Leornardos have enough memory to add proper (configuration/queues/priority handling..) bridge software to redirect/translate from all their I/O to/from the USB-HID port, but that requires the development/maintenance of Arduino software. Now you are in the Arduino development world ...
Find all posts by this user
Quote this message in a reply
05-18-2023, 10:44 PM
Post: #10
RE: The ultimate partner for the HP Prime G2 - The Arduino Leonardo.
Here is the HP Prime program that draws the graph from the USB input. It is basically just an array that has the first byte cut off each loop, and a new byte added, an Graphics buffer G1 is updated with plots and lines and once per loop that Graphics buffer is loaded to G0 and shown on screen. That gives the impression it is moving on screen with time.

The
Code:
  USBOpen();
  USBOpen(9025,32822);
that I use may be different with a different Arduino, you'll have to test that, by entering USBOpen, which will return its address.

Code:
EXPORT USBHIDG()
BEGIN

DIMGROB_P(G1,320,240);
DIMGROB_P(G2,320,240);
DIMGROB_P(G3,320,240);
RECT_P(0,0,320,240,16777215);
LINE_P(0,200,320,200,0);
LINE_P(160,0,160,240,0);
 FOR U FROM 1 TO 20 DO
    LINE_P(U*16,197,U*16,203,0);
 END;
 FOR U FROM 1 TO 8 DO
    LINE_P(157,U*30-10,163,U*30-10,0);
 END;
TEXTOUT_P("5v",138,42,0,RGB(0,0,0),16,RGB(255,255,255));
  RECT_P(0,220,320,240,RGB(240,240,240));
LOCAL T:="USB-HID Graphing Test";
LOCAL A:={};
LOCAL B:={};
LOCAL L:={};
LOCAL CNT:=1;
LOCAL OLDY:=0;

TEXTOUT_P(T,96,224,0,RGB(0,0,0),26*5,RGB(240,240,240));
  BLIT_P(G2,0,0,320,240,G0,0,0,320,240);
  BLIT_P(G1,0,0,320,240,G2,0,0,320,240);
  USBOpen();
  USBOpen(9025,32822);

 FOR U FROM 1 TO 319 DO
    L(U):=0
 END;

REPEAT 
  BLIT_P(G1,0,0,320,240,G2,0,0,320,240);

 FOR U FROM 1 TO 319 DO
    PIXON_P(G1,U,200-L(U),RGB(255,0,0));
    LINE_P(G1,U,OLDY,U,200-L(U),RGB(255,0,0));
    OLDY:=200-L(U);
 END;

  A:=USBRecv();

IF SIZE(A)>0 THEN
  L:=tail(L);
  L(319):=A(1);
  BLIT_P(G0,0,0,320,240,G1,0,0,320,240);
END;

UNTIL ISKEYDOWN(4);

END;
Find all posts by this user
Quote this message in a reply
05-31-2023, 04:28 PM (This post was last modified: 06-04-2023 06:17 PM by Insoft.)
Post: #11
RE: The ultimate partner for the HP Prime G2 - The Arduino Leonardo.
I have UNO and Mega2560, only if I purchased the Mega2560 with OTG at the time, tho I do have an USB Shield so has anyone tried it with the USB Shield as I can’t think why it shouldn’t work and since it’s a Type-A connection I don’t require to purchase a OTG cable.

Tho I’ve just purchase a leonardo, and a OTG cable as I’ve got a number of hardware to attach and be fun exploring that part of the HP Prime calculator
Find all posts by this user
Quote this message in a reply
06-05-2023, 08:48 PM
Post: #12
RE: The ultimate partner for the HP Prime G2 - The Arduino Leonardo.
(05-31-2023 04:28 PM)Insoft Wrote:  I have UNO and Mega2560, only if I purchased the Mega2560 with OTG at the time, tho I do have an USB Shield so has anyone tried it with the USB Shield as I can’t think why it shouldn’t work and since it’s a Type-A connection I don’t require to purchase a OTG cable.

Tho I’ve just purchase a leonardo, and a OTG cable as I’ve got a number of hardware to attach and be fun exploring that part of the HP Prime calculator

What is the Mega 2560 with OTG? That sounds like a great Arduino, the Mega 2560 has more RAM etc, that would make things a bit easier to program on. Do you have a link to the Mega 2560 with OTG?
Find all posts by this user
Quote this message in a reply
06-06-2023, 11:15 AM
Post: #13
RE: The ultimate partner for the HP Prime G2 - The Arduino Leonardo.
This is really cool! Could be a great addition to any school working with calculators and wants to teach programming. We will definitely look into this as a possible workable solution. In case you're interested in supporting us with this, please send me a mail with your details.. Great stuff!

Product Manager HP for MORAVIA Consulting, the EMEA & AP Licensee for HP Calculators.

http://www.hpcalcs.com
Find all posts by this user
Quote this message in a reply
06-06-2023, 06:35 PM (This post was last modified: 06-06-2023 06:55 PM by Insoft.)
Post: #14
RE: The ultimate partner for the HP Prime G2 - The Arduino Leonardo.
(06-05-2023 08:48 PM)matalog Wrote:  
(05-31-2023 04:28 PM)Insoft Wrote:  I have UNO and Mega2560, only if I purchased the Mega2560 with OTG at the time, tho I do have an USB Shield so has anyone tried it with the USB Shield as I can’t think why it shouldn’t work and since it’s a Type-A connection I don’t require to purchase a OTG cable.

Tho I’ve just purchase a leonardo, and a OTG cable as I’ve got a number of hardware to attach and be fun exploring that part of the HP Prime calculator

What is the Mega 2560 with OTG? That sounds like a great Arduino, the Mega 2560 has more RAM etc, that would make things a bit easier to program on. Do you have a link to the Mega 2560 with OTG?

All I remember is when I purchased the Mega 2560. At the time, there was another option next to it that was priced a little higher. It had an extra port, a micro Type-B, alongside the full-size Type-B, and it stated that it was OTG-compatible for Android smartphones. While standing there, I nearly decided to go for it since it might come in handy one day. However, I ultimately decided to stick with the one without. It's a shame that I can't seem to find it again on Amazon. Perhaps it was a one-off item that didn't sell well and was subsequently removed. I really don't know what happened to it.

It was maplin at the time so it could of been a maplin version were they added OTG ?
Find all posts by this user
Quote this message in a reply
06-06-2023, 08:05 PM
Post: #15
RE: The ultimate partner for the HP Prime G2 - The Arduino Leonardo.
(06-06-2023 06:35 PM)Insoft Wrote:  
(06-05-2023 08:48 PM)matalog Wrote:  What is the Mega 2560 with OTG? That sounds like a great Arduino, the Mega 2560 has more RAM etc, that would make things a bit easier to program on. Do you have a link to the Mega 2560 with OTG?

All I remember is when I purchased the Mega 2560. At the time, there was another option next to it that was priced a little higher. It had an extra port, a micro Type-B, alongside the full-size Type-B, and it stated that it was OTG-compatible for Android smartphones. While standing there, I nearly decided to go for it since it might come in handy one day. However, I ultimately decided to stick with the one without. It's a shame that I can't seem to find it again on Amazon. Perhaps it was a one-off item that didn't sell well and was subsequently removed. I really don't know what happened to it.

It was maplin at the time so it could of been a maplin version were they added OTG ?

I doubt that such an Arduino existed from any manufacturer.

Although, something that could have looked very similar could be the Arduino Due, does that look like it? It has lots more SRAM and Flash, but the Arduino USB HID library isn't made to run with it (Another one may, I havent looked at that yet), as it has a 32bit CPU and has many differences. 96KB SRAM and 512KB Flash, which would be amazing for an Arduino.
Find all posts by this user
Quote this message in a reply
06-06-2023, 10:52 PM
Post: #16
RE: The ultimate partner for the HP Prime G2 - The Arduino Leonardo.
(06-06-2023 08:05 PM)matalog Wrote:  
(06-06-2023 06:35 PM)Insoft Wrote:  All I remember is when I purchased the Mega 2560. At the time, there was another option next to it that was priced a little higher. It had an extra port, a micro Type-B, alongside the full-size Type-B, and it stated that it was OTG-compatible for Android smartphones. While standing there, I nearly decided to go for it since it might come in handy one day. However, I ultimately decided to stick with the one without. It's a shame that I can't seem to find it again on Amazon. Perhaps it was a one-off item that didn't sell well and was subsequently removed. I really don't know what happened to it.

It was maplin at the time so it could of been a maplin version were they added OTG ?

I doubt that such an Arduino existed from any manufacturer.

Although, something that could have looked very similar could be the Arduino Due, does that look like it? It has lots more SRAM and Flash, but the Arduino USB HID library isn't made to run with it (Another one may, I havent looked at that yet), as it has a 32bit CPU and has many differences. 96KB SRAM and 512KB Flash, which would be amazing for an Arduino.

It must of been the Duo, and perhaps ? thinking about it now it’s most likely why I went with the Mega, for it’s family AVR and this other board was an overkill for what I was going to use it for at the time.

Tho the Leonardo I have now is I feel was still worth it, such a useful small little board for the HP Prime, just works.
Find all posts by this user
Quote this message in a reply
10-07-2023, 08:55 AM
Post: #17
RE: The ultimate partner for the HP Prime G2 - The Arduino Leonardo.
Bonjour

Je me demande quel type de cordon USB utiliser pour relier directement la Prime à l'Arduino.
Est-ce un câble OTG ?
Merci de bien vouloir m'éclairer.

Hello

I'm wondering what type of USB cable to use to connect the Prime directly to the Arduino.
Is it an OTG cable?
Thank you for your help.

Sorry for my english
Find all posts by this user
Quote this message in a reply
10-07-2023, 03:39 PM
Post: #18
RE: The ultimate partner for the HP Prime G2 - The Arduino Leonardo.
Yes, it is an OTG, the same on both ends, as far as I can tell and it works in either direction. Some Leonardo Micro's have a USB C connector, so just be careful about which one you get.
Find all posts by this user
Quote this message in a reply
10-07-2023, 04:27 PM
Post: #19
RE: The ultimate partner for the HP Prime G2 - The Arduino Leonardo.
(10-07-2023 03:39 PM)matalog Wrote:  Yes, it is an OTG, the same on both ends, as far as I can tell and it works in either direction. Some Leonardo Micro's have a USB C connector, so just be careful about which one you get.

Merci Matalog pour la réponse, pour l'arduino j'ai vérifié son câble va sur la HP donc le même.

Thank you Matalog for the answer, for the arduino I checked its cable goes on the HP so the same.

Sorry for my english
Find all posts by this user
Quote this message in a reply
10-07-2023, 05:19 PM (This post was last modified: 10-07-2023 05:20 PM by matalog.)
Post: #20
RE: The ultimate partner for the HP Prime G2 - The Arduino Leonardo.
I got some of these on ebay; I found them a good short cable https://www.ebay.co.uk/itm/124463761770?...media=COPY.

I hope you can see it.
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)