Wednesday, 29 April 2020

Electronics assembly with Kicad and JLCPCB Assembly

I am shortly getting this assembled:



Thanks to JLCPCB Assembly.

Designed with Kicad  

A big thanks to all EEVBlog forum users and EEVBlog forum user "essele" who created this Kicad plugin for jlcpcb assembly which I have now forked to work with panelised boards

Also thanks to Flemming Frandsen for kicad-util which generated the pcb panelisation. I have forked this to work with Kicad-nightly.




Monday, 16 March 2020

Malenki-nano radio receiver and speed controller

Let's have a look at what I've been working on.

The Malenki-Nano is control module board for robot builders, intended for small robots of 150g or less, where weight and space are important.

Traditionally, a separate receiver and speed controller(s) were used. This is great but it means there are a lot of messy wires to get tangled / broken and take up space inside the robot. The integrated module reduces wiring and is lighter than a traditional rx / esc combination.

My module's specs are:
  • A PCB with radio module mounted on top, dimensions approx 30x20 mm
  • Overall height ~ 10mm (because of the very large crystal oscillator can on the radio, I cannot easily fix this)
  • Electronic speed controller: three channels of DC brushed motors @ 1.8A per channel maximum 
  • Power input - 1-2S lipo pack (minimum ~3.6V, maximum 8.4V)
  • Radio protocol: "AFHDS 2A" which is used by many cheap radios (e.g. those sold by Hobbyking)
  • Antenna: PCB trace "F" antenna (see picture) - seems to give a range of at least 20 metres indoors, which is enough for robot combat.
  • Auxilliary channels - 2x PWM output for other devices e.g. brushed ESC or servo.
  • (NO built-in BEC / 5v regulator; the device uses 3.3v internally)
  • Weight: < 4g excluding wires
 Pictures, or it didn't happen?


http://vectrex.org.uk/mark/back-01.png


Status:
* This module, pictured above, works in its current prototype, but there are a lot of changes I need to do, including swapping the motor driver chips and fixing a few minor problems with the pcb layout. 
I also need to test it with more different transmitters.

Availability:  

I may be able to make some of these boards available to purchase, later in the year 2020. Update: fill in this contact form if you are interested, and I will get back to you.



Wednesday, 1 January 2020

Renewable energy exaggeration

Every year (or more often) we see these "feel good" renewable energy stories such as:

https://news.sky.com/story/more-power-came-from-renewable-energy-than-fossil-fuels-in-uk-in-2019-11898806?dcmp=snt-sf-twitter

I'm not trying to single out Sky News, nor is it really "fake news".

Just somewhat optimistic exaggeration.

Forms of energy

In the UK, energy usage is approximately split three ways, for heating, transport and everything else.
Grid electricity is almost 100% "everything else". So today only about one third of our energy goes through the grid. 
Almost all of the heating and transport is fossil-fuel based, and that's changing only very slowly.
 So even if the grid was to be magically 100% carbon-free (or "renewable", but that's another story) then the other two-thirds would still be mostly fossil fuel.
As far as I can tell, people who haven't read David MacKay's book, usually forget this.
New houses are being built, mostly with gas boilers, which cannot run off renewable energy (NB: I know, biogas etc, is a thing, but not at scale).
 New vehicles are being built which cannot run off anything except fossil fuels.

Fake news or not?

No. The report is from National Grid, who don't monitor non-grid based energy. Heating was not mentioned at all, and transport was only mentioned for future planning.

What's the real story?

Really it should be "Fossil fuels still make 85% of UK's energy". (Or thereabouts)

This doesn't sound so encouraging.

But have a happy new year anyway.

Saturday, 28 December 2019

Reverse engineering the Flower Power app

"Flower Power" is an "internet connected" plant / soil monitoring device which was sold in 2016 by Parrot. The company subsequently decided to discontinue these products to concentrate on its better-known flying drone products.

We acquired some Flower Powers for an environmental study project.

How did it work?

A small low power, very clever monitoring device ( see Sylvia Wu's magnificent teardown ) monitors the environmental conditions, and logs them into a local non-volatile memory. It has a Bluetooth Low Energy (BLE) radio to communicate with smartphones.

Then periodically it synchronises with a smartphone app (available for Android and ios) to send the data up to a "cloud" internet server. The phone app doesn't need to connect to the sensor and the internet at the same time; it can buffer data and send them up later - which is useful if your plants are in a location where internet connection isn't available.

What's the problem?

Parrot have stopped supporting the devices and will switch off the (internet) API soon.

We still have working sensors and want to use them at least next year, maybe after.

There may also be more Flower Powers sitting in storage somewhere; those will become really useless if the API to update the firmware isn't available. I wanted to get the firmware before Parrot turn off their servers.

Reverse engineering


The Android app is a .apk file. I downloaded file from this "sideloading" site here:  


 - of course I don't know if this is the real, unmodified app (from "apkpure"), but it seems likely. I'm not going to load it on a real phone from here.

I extracted the files from .zip formats, and eventually found the "meat" of the application in the .dex files classes.dex classes2.dex and classes3.dex.

These are "Dalvik Executable" files, which are just packed in a different format to .jar - so I' used this utility "dex2jar"  to convert them into .jar

Then I used this Java Decompiler to extract the source code.

I was able to see that the app communicates with https://api-flower-power-pot.parrot.com - but it uses some weird authentication scheme.

Fortunately, the code https://github.com/growobservatory/MyData implements the authentication scheme for this API. 

The "secret" client id and client secret are also hard-coded in the Android app source code, so I was able to log in and call the APIs (and get the api token needed for authentication below).

Using this, I obtained the firmware download location:

wget -S  - 'https://api-flower-power-pot.parrot.com/sensor_data/v1/firmware_update/flower-power' --header="Authorization: Bearer myapitoken"

// Got API token by using MyData

// "flower-power" device
{
   "errors" : [],
   "firmware_version" : "2016-09-14_hawaii-2.0.3_hardware-config-MP",
   "user_config_version" : 39,
   "server_identifier" : "2.1.18 April 6th 2017",
   "firmware_update_url" : "http://hawaii2-web-service-prod-firmware.s3.amazonaws.com/2016-09-14_hawaii-2.0.3_hardware-config-MP.bin?1474470262",
   "garden_status_version" : 219
}

Then I could download (without authentication) the firmware image file.

What next?

Ultimately, if we have any new boxed Flower Powers, I will create an app which flashes the firmware image without using Parrot's cloud servers.

This should allow flashing the devices.

We can also call any of the APIs which the app uses, to get our data from the cloud, plus pictures, etc. (Grow Observatory's Getdata app does some of this)

To be continued... I have all the files downloaded. I suppose if Parrot's servers go away, it gets more interesting.

Also,  this NodeJS project claims it can talk to the Flower Power:

https://github.com/sandeepmistry/node-flower-power 

It also says it can update the firmware.

Sunday, 17 November 2019

Tinyavr toolchain update

Attiny1614 / other tinyavr microcontrollers:

I had a quick go at automating the toolchain build from these instructions

https://github.com/vladbelous/tinyAVR_gcc_setup

After falling down a couple of rabbit holes, I have made a better toolchain build script which is mostly automated and works with many of the chips (attiny3217, 1614 are the only ones I'm targetting).

Build script is here:

https://github.com/MarkR42/robotbits/tree/master/avr_toolchain

The trick was to get a recent subversion avr-libc and patch it with a patch provided from somwhere... details are in the script and it should work.

Now I don't need ot use Vlad Belous hacky method of installing (but thanks anyway, Vlad, it worked ok before). Vlad's instructions to install binutils and gcc were flawless though.

YES!

If you need to build with an open source toolchain, for attiny1614, attiny3217 or others in the same series, try my build.sh script (obviously read it first!)

Sunday, 13 October 2019

Using the ATTINY1614 microcontroller

Microchip / Atmel made some new microcontrollers. This adds to the already huge range of parts.

I've been playing with the ATTINY1614. This is part of the tinyavr 1-series, which is a relatively new (2018?). I get the idea that these new micros are the product of the merger of Microchip and Atmel, so they take the good bits from the older chips of each (but aren't compatible with either).

These are 8-bit MCU with a few kb of ram and a few k of flash (2k and 16k respectively, in this part) which can do quite a lot of work in a small package.

I like them because

  • Small package which is still hand-solderable (soic 14 pin)
  • Tolerate a wide range of supply voltage (2.5-6.5 I think)
  • Small number of passives / extra connections
  • The internal clock generator seems quite accurate
But also

The data sheet doesn't suck. At least, I can understand it.
Peripherals are fairly sane and consistent
One-pin (UPDI) programming interface

Programming with open source toolchain 

See  https://github.com/vladbelous/tinyAVR_gcc_setup - I followed these instructions and they worked.

Flashing the firmware

The firmware programmer is just a serial port, plus one resistor. See https://github.com/mraardvark/pyupdi/ 

 Example code

While it is a relatively new part, there is a bit of sample code "out there".

https://github.com/chromia/attiny1614example - is a useful source of examples.

Also some of the official samples


The product page


Has "Documents" which includes some samples and ideas.

Wednesday, 9 January 2019

Right to repair

SO - if we agree that we have the right to repair things? Does that actually help?

https://therestartproject.org/restart-project/first-ever-protest/

"Right to repair" could be enshrined in law (EU or otherwise) but it won't really help, unless we also have the ability to repair.

Just like Brother/Sister Loretta in Monty Python's Life of Brian, fighting for the right to have babies, but without a womb it's not really useful.
REG: What's the point of fighting for his right to have babies when he can't have babies?!
FRANCIS: It is symbolic of our struggle against oppression.
REG: Symbolic of his struggle against reality.

My experience - Indesit Hob

The Indesit hob was brilliant. It was perhaps, the most amazing thing I've ever repaired. I pulled it to pieces - with standard tools - and the parts were all clear. I easily identified the failed part.

But the best thing was, Indesit supplied a replacement at a reasonable price and delivered it quickly. It was easy to fit and worked first time. The hob works to this day.

Unbranded / Screwfix hedge trimmer

The hedge trimmer worked fine until it hit some metal fencing wire, then it stopped. The culprit was found - despite Torx security screws holding the thing closed - to be a smashed metal helical gear. After reading all documentation and talking to Screwfix. it was clear that a replacement was never going to be forthcoming.

The trimmer got replaced under sale-of-goods "reasonable durability"  but it's definitely a lose. I expect they threw the broken one in the bin (along with a bunch of others with the same fault presumably)

Deraileur gear mech hangers

On bicycles, Deraileur  gears are the most popular. Each bike frame which uses them, has a "mech hanger" which is a sacrifical steel part designed to bend or break if the mech ever ends up in the spokes.

Unfortunately there is no standard for these parts and they come in a dizzying array of shapes and sizes. Manufacturers are not interested in providing spares for discontinued models (even though they might have some stock for current models).

How do we fix our bikes? Several companies now use modern (CNC) techniques to make any mech hanger - and keep databases of designs. These will be available essentially forever because they are made to order and the designs don't consume physical space.

Conclusion

We need companies to provide spares (like Indesit). If they can't economically provide spares, they should provide information which allows other companies to make spares using modern CNC or other techniques (like mech hangers). 
The right to repair is great. The right to have babies is great, if you have a womb.