microbit as ultibo peripheral

General discussion about anything related to Ultibo.
mark
Posts: 1185
Joined: Mon Oct 03, 2016 2:12 am
Location: Indianapolis, US

Re: microbit as ultibo peripheral

Postby mark » Thu Sep 13, 2018 4:19 am

https://github.com/markfirmware/prototy ... 09.12.2349

Each ble packet now has the last 80 a/b up/down events. Pressing the reset on the back of the microbit (interrupts power while depressed) is detected. Depending on state sometimes a lot of excess reporting is made while re-syncing. I will clean that up.

I started on a scheme for encoding the timing but I realized that besides up/down all that is needed for now is the classic double-click, hold, longer hold, longest hold events. I know how to encode them in a way that requires extra events (one to three) in the packet and I'll do that tomorrow. With that I think that I can extract an effective and useful unit from the lpr.

I changed the scan parameter to 0.5 second window every 1 second. The controller remains at 0.1 second broadcast interval.

I'm working through an idea for a model railroad application with ultibo/ble/zerow/pwm/motor in the loco (HO or believe it or not the only train set they had at the store was just one box of a $59 Hornby OO Santa Train loco with two cars.) Constant track power or battery in the loco. So how do you match the microbit to the loco in a roomful of plenty of each? Each zerow/loco assigns itself an n-bit random id (ble broadcast to other locos to settle out on de-duplication). Zero configuration - no need to configure a loco or a controller. How does the operator know which loco is which? Modern interpretive dance, of course. Each unassigned loco when detecting an unassigned microbit will start to dance. One step forward for a 1 bit, one step backward for a 0 bit, four steps for four bits. The operator while looking at the layout will mimic the dance by pressing the B button for a forward step and the A button for a backward step. If the loco agrees, it starts moving forward slowly. Then an A click increases forward velocity and the B click decreases. A held while B is manipulated and B held while A is manipulated can provide more control signals.

While working on the loco mods, I can implement the ultibo side with pwm (logically) routed to some indicator on the hdmi display.

Mark
Ultibo - The Internet of Things that Just Work
mark
Posts: 1185
Joined: Mon Oct 03, 2016 2:12 am
Location: Indianapolis, US

Re: microbit as ultibo peripheral

Postby mark » Fri Sep 14, 2018 1:44 am

I bought the railroad kit. While looking for a jeweler's phillips head (as yet unobtained) I remembered that for isolated track sections each with one loco I can just put the pwm power on the rails. So I can defer updating the loco with a zerow. (And when I do update the loco it might be possible to use dsp code on a zero/adc instead of a zerow if the control rf is applied on the rails. That way I can use my non-wireless zero's. Not any time soon.)

One loco and one loop qualifies. I could use any ultibo pi since they all have usb sockets in which I can plug in ... a microbit using serial/usb ... once that works. I'll stick with 3b+/ble/microbit for the first implementation.

Just need the power amp circuit to get pwm control signal off the pi and onto the variably powered rails. I think a complete layout can mix and match isolated segments where each is either constant voltage (requiring the loco to provide pwm to its motor) or variable voltage (permitting commercial off the shelf locos to run without modification.)

Mark
Ultibo - The Internet of Things that Just Work
Gavinmc42
Posts: 1387
Joined: Sun Jun 05, 2016 12:38 pm
Location: Brisbane, Australia

Re: microbit as ultibo peripheral

Postby Gavinmc42 » Fri Sep 14, 2018 4:04 am

L298 is common simple Dual DCC 2amp power driver, LMD18200 is 5Amp driver.
A google will find you the circuits.

Most of my old stuff is 2mm/N scale narrow gauge but my eyes are to old now, time to go to 16mm/ft on 32/45mm track :D
With that scale, Zero plus cameras are easy.
Hmm perimeter security guard train, that might make it past the finance manager?
What is the cost of G gauge track?
mark
Posts: 1185
Joined: Mon Oct 03, 2016 2:12 am
Location: Indianapolis, US

Re: microbit as ultibo peripheral

Postby mark » Tue Sep 18, 2018 4:52 am

mark wrote:
Ultibo wrote:Nice work Mark.

Thanks.
Ultibo wrote:Based on that there is a good chance that all of the necessary USB support is already available, anyone like to plug the USB into an Ultibo project and see what is reported?
USB 2.0 full speed DAPLink CMSIS-DAP vid 0D28 pid 0204

This is an embedded on-device monitor for development.

See https://github.com/ARMmbed/DAPLink - I only glimpsed the readme but it is a composite usb interface. Mark.


lsusb from raspbian (reformatted):

Bus 001 Device 006: ID 0d28:0204 NXP LPC1768
bDeviceClass 239 Miscellaneous Device
bDeviceProtocol 1 Interface Association
bMaxPacketSize0 64
bNumInterfaces 4

Interface Descriptor:
bInterfaceNumber 0 bNumEndpoints 2 bInterfaceClass 8 Mass Storage
bInterfaceSubClass 6 SCSI
bInterfaceProtocol 80 Bulk-Only
iInterface 7
bEndpointAddress 0x82 EP 2 IN bmAttributes 2 Bulk Usage Type Data wMaxPacketSize 0x0040 1x 64 bytes
bEndpointAddress 0x02 EP 2 OUT bmAttributes 2 Bulk Usage Type Data wMaxPacketSize 0x0040 1x 64 bytes

Interface Descriptor:
bInterfaceNumber 3 bNumEndpoints 2 bInterfaceClass 3 Human Interface Device
bInterfaceProtocol 0 None
iInterface 6
HID Device Descriptor:
bDescriptorType 33
bcdHID 1.00
bCountryCode 0 Not supported
bDescriptorType 34 Report
wDescriptorLength 33
Report Descriptors:
** UNAVAILABLE **
bEndpointAddress 0x81 EP 1 IN bmAttributes 3 Interrupt Usage Type Data wMaxPacketSize 0x0040 1x 64 bytes
bEndpointAddress 0x01 EP 1 OUT bmAttributes 3 Interrupt Usage Type Data wMaxPacketSize 0x0040 1x 64 bytes

Interface Association:
bFirstInterface 1
bInterfaceCount 2
bFunctionClass 2 Communications bFunctionSubClass 2 Abstract (modem) bFunctionProtocol 1 AT-commands (v.25ter)
iFunction 4

Interface Descriptor:
bInterfaceNumber 1 endpoints 1 class 2 Communications subClass 2 Abstract (modem) protocol 1 AT-commands (v.25ter)
iInterface 4
CDC Header:
bcdCDC 1.10
CDC Call Management:
bmCapabilities 0x03
call management
use DataInterface
bDataInterface 2
CDC ACM:
bmCapabilities 0x06
sends break
line coding and serial state
CDC Union:
bMasterInterface 1 bSlaveInterface 2
bEndpointAddress 0x83 EP 3 IN bmAttributes 3 Interrupt Usage Type Data wMaxPacketSize 0x0010 1x 16 bytes

Interface Descriptor:
bInterfaceNumber 2 bNumEndpoints 2 bInterfaceClass 10 CDC Data
iInterface 5
bEndpointAddress 0x04 EP 4 OUT bmAttributes 2 Bulk Usage Type Data wMaxPacketSize 0x0040 1x 64 bytes
bEndpointAddress 0x84 EP 4 IN bmAttributes 2 Bulk Usage Type Data wMaxPacketSize 0x0040 1x 64 bytes


Interface 0 is msd, interfaces 1 and 2 are associated to make the complete cdc function, interface 3 is a hid - this is the daplink interface.

It is interface 3 that ultibo announces in the log and for which it does not have a driver. Has ultibo been tested with composite interfaces? Thanks, Mark.
Ultibo - The Internet of Things that Just Work
mark
Posts: 1185
Joined: Mon Oct 03, 2016 2:12 am
Location: Indianapolis, US

Re: microbit as ultibo peripheral

Postby mark » Tue Sep 18, 2018 11:18 pm

I could only find the word "composite" in locale.pas. Has anyone connected any kind of common composite device? A keyboard with touch pad could be a candidate, but some of them use a wireless usb device that presents a custom vendor device instead of a composite device with two hid interfaces.
Ultibo - The Internet of Things that Just Work
User avatar
Ultibo
Site Admin
Posts: 1980
Joined: Sat Dec 19, 2015 3:49 am
Location: Australia

Re: microbit as ultibo peripheral

Postby Ultibo » Tue Sep 18, 2018 11:42 pm

mark wrote:lsusb from raspbian (reformatted):

Bus 001 Device 006: ID 0d28:0204 NXP LPC1768
bDeviceClass 239 Miscellaneous Device
bDeviceProtocol 1 Interface Association


Interface 0 is msd, interfaces 1 and 2 are associated to make the complete cdc function, interface 3 is a hid - this is the daplink interface.

It is interface 3 that ultibo announces in the log and for which it does not have a driver. Has ultibo been tested with composite interfaces?

Ultibo supports either interface binding or device binding so a single USB device can contain multiple different devices on different interfaces, there are many cases of that and it is used and tested extensively.

What is unusual about this device is the device header which lists bDeviceClass as 239 Miscellaneous Device, most of the generic drivers (storage, mouse, keyboard etc) look for bDeviceClass to be USB_CLASS_CODE_INTERFACE_SPECIFIC in order to accept a device for interface binding so that will explain why the MSD is not appearing. At present I can't see why the CDC device is not recognized but it is likely to be an equally minor variation that is rejecting it as well, assuming you are including the USBCDCACM unit in your project.

Can you attach the complete and unedited output of lsusb for this device so we can work out the best way to deal with these cases?
Ultibo.org | Make something amazing
https://ultibo.org
mark
Posts: 1185
Joined: Mon Oct 03, 2016 2:12 am
Location: Indianapolis, US

Re: microbit as ultibo peripheral

Postby mark » Wed Sep 19, 2018 3:03 am

Ultibo wrote:
mark wrote:lsusb from raspbian (reformatted):

Bus 001 Device 006: ID 0d28:0204 NXP LPC1768
bDeviceClass 239 Miscellaneous Device
bDeviceProtocol 1 Interface Association


Interface 0 is msd, interfaces 1 and 2 are associated to make the complete cdc function, interface 3 is a hid - this is the daplink interface.

It is interface 3 that ultibo announces in the log and for which it does not have a driver. Has ultibo been tested with composite interfaces?

Ultibo supports either interface binding or device binding so a single USB device can contain multiple different devices on different interfaces, there are many cases of that and it is used and tested extensively.

What is unusual about this device is the device header which lists bDeviceClass as 239 Miscellaneous Device, most of the generic drivers (storage, mouse, keyboard etc) look for bDeviceClass to be USB_CLASS_CODE_INTERFACE_SPECIFIC in order to accept a device for interface binding so that will explain why the MSD is not appearing. At present I can't see why the CDC device is not recognized but it is likely to be an equally minor variation that is rejecting it as well, assuming you are including the USBCDCACM unit in your project.

Can you attach the complete and unedited output of lsusb for this device so we can work out the best way to deal with these cases?


I did not have USBCDCACM included.

lsusb:
https://github.com/markfirmware/ultibo-usb-microbit

I'll add a test program (maybe including Paul's usblister) to this repo. Mark.

p.s. I'll add $50 to October's sponsorship to defray the cost of your getting a couple of these. Thanks, Mark.
Ultibo - The Internet of Things that Just Work
User avatar
Ultibo
Site Admin
Posts: 1980
Joined: Sat Dec 19, 2015 3:49 am
Location: Australia

Re: microbit as ultibo peripheral

Postby Ultibo » Wed Sep 19, 2018 11:16 pm

mark wrote:p.s. I'll add $50 to October's sponsorship to defray the cost of your getting a couple of these

Thanks Mark, A quick check of our regular suppliers in Australia shows that the Micro:bit is currently out of stock so we'll have to check around some alternates to see if anyone has them available.

In the meantime I'm trying to find something definitive in the USB specs about what should be shown in the bDeviceClass field of the device header and also what Linux and others test for.
Ultibo.org | Make something amazing
https://ultibo.org
Gavinmc42
Posts: 1387
Joined: Sun Jun 05, 2016 12:38 pm
Location: Brisbane, Australia

Re: microbit as ultibo peripheral

Postby Gavinmc42 » Thu Sep 20, 2018 2:04 am

Garry, try these guys, I seem to be getting more and more from them because they have stock at reasonable prices for OZ.
https://core-electronics.com.au/micro-bit-by-bbc.html
User avatar
Ultibo
Site Admin
Posts: 1980
Joined: Sat Dec 19, 2015 3:49 am
Location: Australia

Re: microbit as ultibo peripheral

Postby Ultibo » Thu Sep 20, 2018 11:19 pm

Gavinmc42 wrote:Garry, try these guys, I seem to be getting more and more from them because they have stock at reasonable prices for OZ.
https://core-electronics.com.au/micro-bit-by-bbc.html

Thanks Gavin, ordered and on the way from Core Electronics!
Ultibo.org | Make something amazing
https://ultibo.org

Return to “Discussion”

Who is online

Users browsing this forum: No registered users and 0 guests