HP Forums

Full Version: The holy grail of the BEEP(1400, 0.08) command: USB-HID
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
With the latest HP Prime public release (2021 12 02 (14603)) the HP Prime now has another stable trick: the USBOpen(), USBSend() and USBRecv() commands. These commands are used to communicate over an USB connection using the USB-HID protocol.

Besides communicating to sensors, analog<->digital (A/D, D/A) and General Purpose Input/Output (GPIO), there are also many serial interfaces to, for example, test equipment, EEPROM readers/writers, and radio/GPS interfaces. So <then> the retrieved data can be used within the mighty Prime math machine.

To implement an HP Prime USB-HID connection, the goal was to have no other major software development other than on the HP Prime. Although a Raspberry PI/Arduino-like solution might work, the USB-HID interface and its HID device descriptors might be too high of a bar/maintenance for self deployed solutions.

A cheap (<US$20), off-the-shelf solution was found in using the UMFT260EV USB-HID interface. There are other USB-HID converters available, but this one appears to have good documentation/examples.

The HP Prime USB-HID implementation is based on a single endpoint, interrupt only, implementation. Only GET/SET reports are used to communicate on this USB-HID interface.
This limits the configuration of the FT260 to using the default settings only: many settings are done by GET/SET feature reports (unless configured off-line). But the default settings for the I2C interface are all we need! The additional features now lost on the FT260 (GPIO and UART functionality), can be made up by cheap GPIO/UART I2C add-ons.

The UMFT260EV out of the box, no jumper changes, and only HP-PPL, provides access to the I2C interface. This allows access to the EEPROMs, as well as for example sensors and multiple UARTs/GPIOs etc.

Here are some examples of reading sensors, I2C registers, a serial port loopback in single byte as well as FIFO mode.
Finally an HP Prime->USB-HID->I2C->UART->MP3->Speaker will guide us to the holy grail of the BEEP(1400,0.08) command! Hope this will inspire you!

bme680_conf.jpg, bme680.jpg : Reading BME680 Chip id, status, temperature (21 C), pressure (993 mbar), humidity (49%) and gas resistance (20k).
I2Cregs.jpg : Reading the dual UART at I2C address 0x10h, 2 UARTs enabled (reg 0, 0xB3h), reading page 1 (reg 3, 0x01), baud rate 0x05Fh (9600) at reg 0x04~0x06.
UART.jpg : UART2 in loopback (yellow jumper), sending/receiving single char (RX1), or FIFO burst (RXF)

Incl. are example FT260-I2C routines that work on a real Prime:
• UClr() - USB flush rx buffer
• UClose() - USB close
• ft260_open() - open FT260
• ft260_recv() - generic receive (I2C and UART)
• ft260_i2cReadReq() - I2C: full write/read cycle read request
• ft260_i2cSend() - I2C: write data to i2c
• ft260_EEPROMrdall() - read the FT260 EEPROM
• hid2c() - reading/writing to I2C registers

HP Prime G2, HPL Version 14598 or higher required (Many thanks to CyrilleB for the extended help!)
Future Technology Devices UMFT260EV: USB-HID to I2C interface (larger blue circuit board)
Bosch BME680 : I2C Sensor temperature, pressure, humidity and gas detection
DFRobotics DFR0627 : I2C dual UART
Seed Studio MAX232: RS232 level converter (not shown)
(Currently the emulator fails on USBSend(), and it also reports an incorrect HID descriptor size upon USBOpen() commands.)
Great work, my UMFT260EV is on order!
You mentioned GET/SET Feature Reports cannot be used to set UART mode, due to interface limitations. Did I understand correctly it could be done using jumpers on the UMFT260EV ie. JP9=1 JP7=0 , and then one could GET/SET communicate with the UART?
Absolutely! JP7 LOW (2,3) and JP9 HIGH (2,1) will do the trick to enable the UART (do not let those pins float..)
If JP7/JP9 are both at the same level, I2C is the first HID interface reported and used by the Prime (although both interfaces appear in an USBOpen()).
So if you can live with the default settings of N81, 19200, that is what you get. The UART interrupt report is also enabled, the code currently does not deal with it much (line 109), but is available as another input signal.
The only code change required is the opcode in the sending routine to indicate the FT260 UART, changing from 207 to 239 (line 140).

I initially had the opcode dynamic, based on ft_io setting (line 24). I ran a long time the UART only (YAT (terminal), SimpleHID (HID utility) on a PC), as well as on the Prime. But after a very reliable source mentioned about the interrupt only operations on the Prime, I moved on to the I2C interface since I needed different baud rates. If you keep power to the FT260 'somehow' (small battery/caps), you can configure the UART on a different computer. But what fun is that?

You can use the ft260_recv() routine for receive. Receive even works on the emulator (using SimpleHID to get/set features manually(!), then close SimpleHID and use the Prime/UART)
You have to watch out for buffer over runs, (Prime , FT260 at 64 bytes) So you might need a WAIT(0.1) between sending and receiving cycles, and/or play with the block size in the send routine.
(You can copy the code from ft260_i2cSend() into ft260_USend(), change the opcode and block size (bsize) for UART operations.)

And remember, the TX/RX lines are 0~3.3V out of the FT260, not RS232 (but an HP50 will like that...)

Here is a receive terminal program I used (exit still declared in the previous provided example):


EXPORT ft260_Term() // loop to receive UART data until <esc>
LOCAL txt;
PRINT();PRINT("FT260 terminal started");
  IF SIZE(txt)>0 THEN 
    PRINT("RX: "+STRING(CHAR(txt))); 
UNTIL exit;
... this is a very nice Christmas present! An I2C interface opens a whole world of interesting applications. But first I need to get an USB-Micro <> USB-Micro cable. Or did you use a combination of two cables with an USB-A interface in the middle?
(12-27-2021 02:08 PM)Martin Hepperle Wrote: [ -> ]... this is a very nice Christmas present! An I2C interface opens a whole world of interesting applications. But first I need to get an USB-Micro <> USB-Micro cable. Or did you use a combination of two cables with an USB-A interface in the middle?

My Prime came with one.
Does this work only on hardware C of the Prime right?
When you all be used with that solution would you mind creating a sort of ‘how to’ for us who are not on top of electronic like you?

That seems very promising. I am interested in reading sensors and driving devices from my Prime.

Great job!

(12-30-2021 04:31 PM)Giancarlo Wrote: [ -> ]Hello,
Does this work only on hardware C of the Prime right?
When you all be used with that solution would you mind creating a sort of ‘how to’ for us who are not on top of electronic like you?

That seems very promising. I am interested in reading sensors and driving devices from my Prime.

Great job!


The commands are active even on hardware A but I don't know if they work properly or not.

Another question: Is the hid-usb board powered by the prime or it requires a separated power source?


Excellent work!
‘..Is the hid-usb board powered by the prime or does it require a separated power source?..’

A very good question. The short answer: the FT260 evaluation board and the sensors are currently powered by the Prime through a micro USB<->micro USB cable.

An HP Prime that meets the USB 2.0 specs <should> deliver at least 100mA. Someone Smile might be able to chime in here (Fuse 1201 'B' ?). All I have as a reference are the open kimono pictures of the wireless kit at https://fccid.io/U6OG0S02/Internal-Photo...to-2149279 and its PID/VID 1915/0101 confirmation of Nordic that leads to https://www.sparkfun.com/datasheets/Wire...%20package. The nRF24LU receiver pulls about 14mA (assuming the RX and TX do not work simultaneously, and the TX pulls only 7.5mA at -12dBm). My guess is the Prime can at least deliver twice that to be reliable (about 25-50mA).

Per the data sheet of the UMFT260EV1, there are various power options. The FT260 takes at the most 25mA, but since the UART/GPIO are suspended in our case, it is probably about 20mA. The FT260 can deliver 100mA, so if you use the FT260 to power your sensor(s) there is about 75mA left (but can the Prime deliver?) It also can provide the 3.3V for many sensors.

As long as you do not plan to run some crazy PWM led drivers to control your Lego Technic motors, you should be ok to connect a low current sensor. I have no problem with the Bosch sensor at 12mA max.

My advice, start with the FT260 only, and then try to read its I2C EEPROM. Then a simple basic I2C sensor, ensure you have the application sheet/programming and pins hookup (The DFR0627 UART spec is all in Chinese, and I had to depend on online translations…I would probably go with a B083D27NJD from waveshare as an alternate). Figure out the power (ground, 5V or 3.3V – keep them separate!) and the I2C Clock and Data lines (4 wires total, incl. power). If you need more power (speakers/LEDs/more common wifi/Bluetooth modem) you might need an external power source.

Hello and thank you very much for the long explanation.
That makes me feel really unprepared to deal with such technology without clear indications :+)

I understand that depending on the sensor or actuator we should need an external power source or not.

Regarding the speaker, do you think I would need an extra source? I don’t have to play songs, just few beeps. I used to do some time tracking with my calculator and create project reports based on time spent.


With the calc connected to the UMFT260, then the FT260 connected to an Arduino (powered by it's own source) via I2C, do you think that we could read from the analog inputs of the Arduino and get sensor data that way, then pass them back to the calc?

To be honest i'd be happy with a BEEP feature, and if you can offer any very simple instructions, then I will give it a go. Although, all of the suppliers of these devices https://www.mouser.co.uk/ProductDetail/F...B6hw%3D%3D seem to have them on back order at the minute.

Has anyone found any currently available?
(01-02-2022 11:15 PM)matalog Wrote: [ -> ]Has anyone found any currently available?

In UK (and Europe) you can get it from Farnell.
I have got no Prime (yet), but all this sound pretty interesting for STEM education, doesn't it? I will certainly keep an eye. Thanks to the OP!
Some civilized ways to break out of a Prime and generate on-demand-audio-requests are:
- screen (camera/light sensor)
- RF interference
- USB-HID USBSend() command to a proper audio device (MP3/GPIO-Piezo)

If one is not interested in an I2C interface or an UART for its intended purpose, then the USBSend(data)->USB-HID->UART TX-data (passive piezo), or its TX_Active pin (active piezo), can drive a piezo (at 3.3v, max 4mA, sounds like a bb.hamster in distress). Some amplifier/transistor to a piezo can enhance the audio: they typically require more than the output current of those pins.

If the Arduino can act as an I2C slave it probably could be programmed to forward any of its data.
(01-05-2022 03:24 PM)gehakte_bits Wrote: [ -> ]If the Arduino can act as an I2C slave it probably could be programmed to forward any of its data.

I would like to try to get that to work. Where could I find the relevant information for the HP Prime end of things? i.e. how to set the prime up for receiving data. Actually any relevant sites or documents would be appreciated.
Guess an arduino USB host shield will work as well to comminicate with the Prime ?
If it works then its possible to communicate all arduino features to the Prime.
I'm looking forward to giving this a go. Any chance that you could update the photos of the breadboards as they are rather low resolution?

I would be interested in more details about using the internal UART on the UMFT260EV board for a serial connection to HP48 or another serial device such as a server console port. Is the RS232 level converter needed and is it capable of being driven from the Prime or is another power supply needed?

PS. Thank you Didier for the Farnell link. My order has been submitted.
The UART in the FT260 is very well done (see its specs). But you cannot use feature reports on the Prime to configure the UART, since the Prime only supports get/set reports. You are now limited to the default UART settings of N81, 19200 baud (not supported by the hp48 I think). These limitations make the I2C interface a no brainer to use.

The FT260 UART TX/RX levels are 3.3V. If you need true RS232 levels you will need a converter (i.e. MAX232). It can be powered from the Prime. You might see degraded performance once the Prime is below 25% battery level.

My latest rendition has most wires covered, with access to the I2C, UARTs and USB port on the outside of the breadboard.
I'm struggling to work out which pins on the FT260 connect to SDA and SCL on the BME260, and the FT260 datasheet doesn't help. Could you clarify?

Many Thanks,
Pages: 1 2
Reference URL's