Contents
- 1 Disclaimer
- 2 Fold handling
- 3 Me relying on relaying BLE?
- 3.1 Rationale
- 3.2 Decomposing Fig.1 Sum of suggestions
- 3.3 Bluetooth must be plug and play in all aspects
- 3.4 Where to find these boards
- 3.5 ACBox = Aquarium Controller Box dev
- 3.6 ACBox = Aquarium Controller Box inside
- 3.7 W.2a = WiFi board direct usage
- 3.8 BLE-51.1 or BLE-51.2 = BLE as left relay board
- 3.9 BLE-52 = BLE as right relay board
- 3.10 W.2b = WiFi board RBox usage
- 3.11 E = Wired RJ45 Ethernet
- 3.12 DCat = Desktop Catalyst
- 4 Questions
- 5 Conclusion
This page is in group Technology (plus My XMOS pages) and is a blog note where I will discuss the route ahead. Should I do the My WiFi101 library port as I promised myself to try, or should I add a second box that I talk with over BLE (Bluetooth Low Energy)? Conclusion 23Dec2017: I did neither; I went for a simpler(?) radio solution, discussed in my next note My aquarium’s data radioed through the shelf. This note will still take you through the general architecture, much of it is also present in the radio solution.
Disclaimer
Standard disclaimer, this is just for fun. No money, gifts, ads etc. Also, my non-association with any of the companies mentioned here. Other than some times exchanging technical matters, mostly in open forums. I am basically positive until I may have experienced the opposite; this is reflected in all my blog notes.
Fold handling
Collapse All |
Example
Use «Expand All» (above) to make all folds expanded: visible, searchable and printable!
Me relying on relaying BLE?
I am folding these chapters since they are so tied to the figure:
Rationale
The above figure shows several alternatives that I will discuss here.
Don’t discard this because you think I’m headed for a complicated solution. As I said in an earlier note (151):
As an engineer I am concerned that I should end up with a «product». However, as a retired engineer I will try to enjoy the road even more than I did at work. Therefore I am not after the shortest path, but the most interesting part.
Decomposing Fig.1 Sum of suggestions
I have concluded that this would fail, so I added a second box, the Relay Box (RBox) situated on the shelf below the aquarium. It would take its data from ACBox over Bluetooth Low Energy (BLE) boards. Either the BLE-51.1 (Adafruit 2479 with UART) or BLE-51.2 (Adafruit 2633 with SPI) inside ACBox (piggy-backed to be plugged into the vacant SPIe slot there). Observe that unlike the Aquarium Controlled Box, which has relays, the Relay Box does not have any relays! It just relays data.
The chosen board on the left side would talk over BLE with the right side and the BLE-52 board in the RBox. The exciting thing with BLE-52 is that it contains a new, free operating system by Apache. (Cut and paste from Wikipedia’s Apache Mynewt article): Apache Mynewt is a modular real-time operating system for connected Internet of things (IoT). (..) The name Mynewt is wordplay on the English word minute, meaning very small: the kernel is only 6 KB in size. The OS is designed for connectivity, and comes with a full implementation of the Bluetooth low energy 4.2 stack. It’s got preemptive multithreading, semaphores, mutexes and event queues. With the mentioned xC language and the xCORE boards, that’s basically what’s in the hardware and the language on that side. Still, I just can’t wait to see how it’s built.
The RelayBox (RBox) is an XMOS board that has been extensively described in My xCORE-200 eXplorerKIT notes (WiFi). Moving the WiFi board W.2a over there and call it W.2b to run a port of WiFi101 is one option. But then I have to do that port. Another possibility is to connect it over the RJ45 Ethernet connector (E) to a switch that’s just below the aquarium, too – and run the XMOS web server on the RBox. (Below you’ll see that this is a far stretch..)
These Adafruit boards and the porting jobs would start on the Desktop Catalyst (DCat) (Adafruit 2772) running the Arduino IDE. W.2a already runs on DCat, but not on ACBox.
Bluetooth must be plug and play in all aspects
- I don’t want to delve into native Bluetooth tools, like the Software Development Kit for Bluetooth from Nordic. They show these tools here. This is the reason I go for the Adafruit breakout boards, that have Adafruit code also added to the Nordic chips embedded inside the Raytac modules. I guess Adafruit has had to relate to the Nordic tools. Some (?) of these tools are supported by Keil, IAR or GCC. To a home-programmer that’s not good news. I have worked with all of those at work, and I’d like something less licence-ridden, less Windows-centric now!
- In other words (1) I want to do precompiled bonding and pairing (all needed keys etc. stored as constants in the code or as data in FLASH), and I want connecting and reconnecting to be automatic when each unit is powered, without user interaction. I think that Secure Simple Pairing (SSP) of type Just works is what I’m after (more on Wikipedia). The connection must be permanent in all aspects of it
- In other words (2) I don’t (too much anyway) want to associate, pair, scan, or worry about connections (so I have to worry..? Freely from Adafruit LoRa packet radio break out board description, see here.
- Update 23Dec2017: This is the point where I, after thinking about all BLE matters subsided into my next note: My aquarium’s data radioed through the shelf). And actually went for that solution!
- In other words (3) I don’t want to be a member or pay fees to the Bluetooth organisation at https://www.bluetooth.com
- I don’t want to buy the Segger J-Link JTAG/SWD debugger box (here). I think that’s what ARM developers need when they want more than printf and a LED debugging. So it’s really necessary if it’s ARMs I’m going to work extensively with. I’ll try to avoid that now. (Until I might get time to port/rewrite a CSP channel based scheduler that runs all over the world in cruise ships at the moment, see here). The DCat (below) does not have a connection for JTAG/SWD, but the BLE-52 would
- That being said, I do have an xCORE board with a processor with 7 logical xCOREs and one ARM core on the chip. It cross-debugs across those two platforms with the xTIMEcomposer tool. But XMOS obsoleted it. See here
- The price for my limited wishes may be that I probably will not be able to update the Nordic chips, should that be necessary. Both the BLE protocol stacks for nRF51822 and nRF52832 are available for download through a scheme called SoftDevice (here)
Where to find these boards
- ACBox: Aquarium Controller Box. XMOS startKIT. 1 tile, 8 logical cores for user: https://www.xmos.com/support/boards?product=17441
- RBox: Relay Box. XMOS xCORE-200 eXplorerKIT. 2 tiles, 16 logical cores for user: https://www.xmos.com/support/boards?product=17441
- W.2a & W.2b: Adafruit ATWINC1500 WiFi Breakout (2999) (With Atmel/Microchip module): https://www.adafruit.com/product/2999
- BLE-51.1: Adafruit Bluefruit LE UART Friend (2479) (Raytac MDBT40 with Nordic nRF51822 with ARM Cortex M0): https://www.adafruit.com/product/2479
- The nRF51822 page is at https://www.nordicsemi.com/eng/Products/Bluetooth-low-energy/nRF51822/(language)/eng-GB
- Raytac MDBT40 is at http://www.raytac.com/products.php?id=2 or at Nordic’s page here: https://www.nordicsemi.com/eng/Products/3rd-Party-Bluetooth-low-energy-Modules
- BLE-51.2: Adafruit Bluefruit LE SPI Friend (2633) (Raytac MDBT40 with Nordic nRF51822 with ARM Cortex M0): https://www.adafruit.com/product/2633
- The nRF51822 data sheet is shown above
- BLE-52: Adafruit Feather nRF52 Pro (3574) (Raytac MDBT42Q with Nordic nRF52832 with ARM Cortex M4F) (However Apache’s mynewt OS): https://www.adafruit.com/product/3574
- The nRF52832 page is at https://www.nordicsemi.com/eng/Products/Bluetooth-low-energy/nRF52832
- Raytac MDBT42Q is at http://www.raytac.com/products.php?subid=54 and also mentioned Nordic page (At BLE-51.1 above)
- DCat: Desktop Catalyst . Adafruit Feather M0 Basic Proto ATSAMD21 Cortex M0 (2772): https://www.adafruit.com/product/2772
ACBox = Aquarium Controller Box dev
Constraint check for tile[0]: Cores available: 8, used: 7 . OKAY Timers available: 10, used: 8 . OKAY Chanends available: 32, used: 27 . OKAY Memory available: 65536, used: 53232 . OKAY (Stack: 5572, Code: 41634, Data: 6026)
See, it’s quite different (Cores, Timers, Chanends) from the Arduino, which when I compile the SimpleWebServerWifi would show something this:
Sketch uses 42192 bytes (16%) of program storage space. Maximum is 262144 bytes. Atmel SMART device 0x10010005 found Device : ATSAMD21G18A Chip ID : 10010005 Version : v2.0 [Arduino:XYZ] Mar 5 2016 17:46:52 Address : 8192 Pages : 3968 Page Size : 64 bytes Total Size : 248KB Planes : 1 Lock Regions : 16 Locked : none Security : false Boot Flash : true BOD : true BOR : true Arduino : FAST_CHIP_ERASE Arduino : FAST_MULTI_PAGE_WRITE Arduino : CAN_CHECKSUM_MEMORY_BUFFER Erase flash done in 0.789 seconds Write 42592 bytes to flash (666 pages) [== ] 9% (64/666 pages) [===== ] 19% (128/666 pages) [======== ] 28% (192/666 pages) [=========== ] 38% (256/666 pages) [============== ] 48% (320/666 pages) [================= ] 57% (384/666 pages) [==================== ] 67% (448/666 pages) [======================= ] 76% (512/666 pages) [========================= ] 86% (576/666 pages) [============================ ] 96% (640/666 pages) [==============================] 100% (666/666 pages) done in 0.236 seconds Verify 42592 bytes of flash with checksum. Verify successful done in 0.028 seconds CPU reset.
The xCore processors are multicore Microcontroller: XMOS Multicore Microcontrollers are programmable devices that consist of one or more xCORE tiles, each running up to eight 32bit logical processing cores. Each logical core can process I/O, DSP and application code concurrently, and shares an integrated SRAM memory. xTIME schedulers make sure that each core runs to completion without deadlock, providing a completely deterministic software programmable device that can be used to implement tasks traditionally implemented in hardware. (From the XMOS glossary of terms, here)
ACBox = Aquarium Controller Box inside
W.2a = WiFi board direct usage
Another matter is that should I be able to fit a web server into the Aquarium Controller Box ACBox (as mentioned, I won’t), then building html pages may be another far stretch. Plus, I want to do much more logging, like seeing what’s happening with the temperature regulator when the night’s lowering of the room temperature is active. The electrical ovens do this automatically, but the aquarium’s regulator has of course to follow to keep the 25 deg C water temperature. For this logging the xCORE-200 eXplorerKIT RBox would be a perfect fit. And of course, do the html building.
BLE-51.1 or BLE-51.2 = BLE as left relay board
Low level comms
I am interested in the low-level communication with the Adafruit UART Friend, since I need to figure out if it’s easier to talk with it from the xCORE than using SPI.
Nordic NRF51822 / Bluefruit LE
- UART. Standard with start bit, 8 data bit, optional(?) parity bit and optional(?) stop bit. Needs CTS and RTS as well
- I had to dig to try to establish this: From Adafruit: «Transport: UART @ 9600 baud with HW flow control (CTS+RTS required!)». From here: reflecting Nordic’s nRF51 UART I/O: Pin 10 TXO is data out of Bluefruit LE, pin 9 RXI is data into Bluefruit LE, pin 11 CTS pulls data from Bluefruit LE while pin 8 RTS must be low to push data to Bluefruit LE. They are 3.3V or 3.5V level. The nRF51822 data sheet (above) shows in 4.12 that «The Universal Asynchronous Receiver/Transmitter offers fast, full-duplex, asynchronous serial communication with built-in flow control (CTS, RTS) support in hardware up to 1 Mbps baud. Parity checking is supported. The GPIOs used for each UART interface line can be chosen from any GPIO on the device and are independently configurable. This enables great flexibility in device pinout and efficient use of board space and signal routing.» It doesn’t even specify data width! I just assume it’s data 8 bits, as most UARTs have been fom the beginning of time. See Wikipedia. It looks to me from here that the data sent or received is indeed standard 8 bit – size_t (uint8_t c). From here (point 12) it looks like there is also is an optional stop bit. It must be when it’s a UART and not a USART. Likewise there must be a start bit
- SPI. Standard SPI. I’ve already tested this on the W.2a WiFi board
XMOS
- UART. The Generic UART SW (here) uses 2110 bytes of code, two 1-bit ports and two channel ends. But I would have to add CTS and RTS myself
- SPI. I have already used this, search for sci_slave (older) and lib_spi (newer) in My xCORE-200 eXplorerKIT notes (WiFi). From here I read that it uses 4 one-bit ports and about 0.8k code
From this it seems like I should go for SPI.
BLE-52 = BLE as right relay board
W.2b = WiFi board RBox usage
E = Wired RJ45 Ethernet
Update 19Dec2017. This turned out not to be so simple if I’m going to use XMOS SW. It doesn’t seem to exist for the xCORE-200 eXplorerKIT which uses RGMII (not MII) with its PHY. However, it should be possible to use RGMII, since [lib_ethernet] supports both RGMII and MII! See note My single-board boards and why notes chapter Conclusion and todo list point 3 – that will point you to other places. (Aside: I can find a converter out there from GMII (not MII) to RGMI, but that’s of course an ASIC FPGA library from Intel. It’s at Embedded Peripherals IP User Guide, Intel UG-01085 at 2017.11.06, chapter Intel FPGA GMII to RGMII Converter Core, here.)
Aside: Search for «lib_webserver» in My xCORE-200 eXplorerKIT notes (WiFi). But the XMOS url is here: https://www.xmos.com/support/libraries/lib_webserver. I have a quite interesting question at the xCore Exchange, about a pattern that they use in module_mutual_thread_comm where they do mutual bidirectional communication between two threads with only one channel. See here (however, it hadn’t been answered by any last time I checked).
DCat = Desktop Catalyst
Questions
- Adafruit Forum: Code size for Bluefruit LE UART/SPI Friend? (Dec2017)
- Adafruit Forum: Bluefruit nRF51 talking with Feather nRF52 Pro plug and play? (Dec2017)
Conclusion
I think I will continue to keep all my conclusions to the same chapter, in a previous blog note. See My single-board boards and why note, chapter Conclusion and todo list. Since I have written so many notes that at first glance look like they’re all equal, that may help connect the threads. That being said and since I have already mentioned it, I did go for a simpler(?) radio solution, as discussed in my next note My aquarium’s data radioed through the shelf.