The holy grail of the BEEP(1400, 0.08) command: USB-HID
12-23-2021, 03:57 PM (This post was last modified: 12-26-2021 05:01 PM by gehakte_bits.)
Post: #1
 gehakte_bits Junior Member Posts: 6 Joined: Dec 2021
The holy grail of the BEEP(1400, 0.08) command: USB-HID
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_i2cSend() - I2C: write data to i2c
• ft260_EEPROMrdall() - read the FT260 EEPROM
• hid2c() - reading/writing to I2C registers

References:
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.)

Attached File(s)
12-24-2021, 08:57 AM
Post: #2
 Stevetuc Member Posts: 299 Joined: Jan 2014
RE: The holy grail of the BEEP(1400, 0.08) command: USB-HID
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?
12-24-2021, 04:22 PM
Post: #3
 gehakte_bits Junior Member Posts: 6 Joined: Dec 2021
RE: The holy grail of the BEEP(1400, 0.08) command: USB-HID
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):

Code:
 EXPORT ft260_Term() // loop to receive UART data until <esc> BEGIN LOCAL txt; ft260_open(); PRINT();PRINT("FT260 terminal started"); REPEAT   txt:=ft260_recv();   IF SIZE(txt)>0 THEN      PRINT("RX: "+STRING(CHAR(txt)));    END; UNTIL exit; UClose(); END;
12-27-2021, 02:08 PM (This post was last modified: 12-27-2021 02:11 PM by Martin Hepperle.)
Post: #4
 Martin Hepperle Senior Member Posts: 333 Joined: May 2014
RE: The holy grail of the BEEP(1400, 0.08) command: USB-HID
... 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, 04:59 PM
Post: #5
 toml_12953 Senior Member Posts: 1,907 Joined: Dec 2013
RE: The holy grail of the BEEP(1400, 0.08) command: USB-HID
(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.

Tom L
Cui bono?
12-30-2021, 04:31 PM
Post: #6
 Giancarlo Member Posts: 257 Joined: Dec 2013
RE: The holy grail of the BEEP(1400, 0.08) command: USB-HID
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!

Giancarlo
12-30-2021, 05:25 PM
Post: #7
 toml_12953 Senior Member Posts: 1,907 Joined: Dec 2013
RE: The holy grail of the BEEP(1400, 0.08) command: USB-HID
(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!

Giancarlo

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

Tom L
Cui bono?
12-30-2021, 07:27 PM (This post was last modified: 12-30-2021 07:28 PM by Giancarlo.)
Post: #8
 Giancarlo Member Posts: 257 Joined: Dec 2013
RE: The holy grail of the BEEP(1400, 0.08) command: USB-HID
Thanks.

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

Thanks

Giancarlo
12-31-2021, 03:27 PM
Post: #9
 agarza Member Posts: 97 Joined: Oct 2016
RE: The holy grail of the BEEP(1400, 0.08) command: USB-HID
Excellent work!
12-31-2021, 04:03 PM (This post was last modified: 12-31-2021 04:40 PM by gehakte_bits.)
Post: #10
 gehakte_bits Junior Member Posts: 6 Joined: Dec 2021
RE: The holy grail of the BEEP(1400, 0.08) command: USB-HID
‘..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 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.

Enjoy!
01-02-2022, 07:33 PM
Post: #11
 Giancarlo Member Posts: 257 Joined: Dec 2013
RE: The holy grail of the BEEP(1400, 0.08) command: USB-HID
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.

Thanks

Giancarlo
01-02-2022, 11:15 PM
Post: #12
 matalog Member Posts: 205 Joined: May 2021
RE: The holy grail of the BEEP(1400, 0.08) command: USB-HID
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-03-2022, 06:31 AM
Post: #13
 Didier Lachieze Senior Member Posts: 1,496 Joined: Dec 2013
RE: The holy grail of the BEEP(1400, 0.08) command: USB-HID
(01-02-2022 11:15 PM)matalog Wrote:  Has anyone found any currently available?

In UK (and Europe) you can get it from Farnell.
01-03-2022, 09:08 PM
Post: #14
 Luigi Vampa Member Posts: 263 Joined: Dec 2015
RE: The holy grail of the BEEP(1400, 0.08) command: USB-HID
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!

Saludos Saluti Cordialement Cumprimentos MfG BR + + + + +
Luigi Vampa +
Free42 '<3' I + +
01-05-2022, 03:24 PM
Post: #15
 gehakte_bits Junior Member Posts: 6 Joined: Dec 2021
RE: The holy grail of the BEEP(1400, 0.08) command: USB-HID
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, 09:26 PM
Post: #16
 matalog Member Posts: 205 Joined: May 2021
RE: The holy grail of the BEEP(1400, 0.08) command: USB-HID
(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.
01-07-2022, 07:20 AM
Post: #17
 Graan Member Posts: 104 Joined: Dec 2013
RE: The holy grail of the BEEP(1400, 0.08) command: USB-HID
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.
01-10-2022, 06:07 PM
Post: #18
 Mark Power Member Posts: 79 Joined: Dec 2013
RE: The holy grail of the BEEP(1400, 0.08) command: USB-HID
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.
01-11-2022, 02:40 AM
Post: #19
 gehakte_bits Junior Member Posts: 6 Joined: Dec 2021
RE: The holy grail of the BEEP(1400, 0.08) command: USB-HID
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.

01-14-2022, 09:29 PM
Post: #20
 Mark Power Member Posts: 79 Joined: Dec 2013
RE: The holy grail of the BEEP(1400, 0.08) command: USB-HID
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,
Mark.
 « Next Oldest | Next Newest »

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