Author: cebalo

LoRaWAN Gateway

Recently I have been playing with LoRa radio transceivers. – Long Range, low power.

I found it is easy to to setup a point to point link with two LoRa modules but as soon as you start playing with the LoRaWAN protocol, you find you need a gateway device to go much further.

RAKWireless recently released a low cost gateway concentrator board – the RAK831.

Most current DIY gateways use the Raspberry Pi to drive the gateway board. I looked at using this with the RAK831 but decided to try and find a neater/smaller solution.

Enter the NanoPi Neo.  Friendly Elec – http://www.friendlyarm.com/ sell the NanoPi Neo – significantly cheaper and smaller than the full sized Raspberry Pi and easier to use than the Raspberry Pi Zero.

Here’s a board with the NanoPi Neo that also supports a GPS module, OLED display and BMP280/BME280 sensor. All these are of course optional and the board only needs a few resistors to operate as a gateway.

NanoPi-RAK

The GPS module is a UBLOX Neo 7m. This has a USB interface to allow the GPS module to be configured. The PPS output is made available to the RAK831 along with the serial data output to the NanoPi Neo on serial port 1. I have provided a jumper to disable/enable the Nano transmit/GPS receive line. I found that the echo from the Nano would cause the GPS serial port problems…and sometime stop valid data being sent from the GPS.

You could also disable serial port echo on the Nano if needed.

The OLED display is a 128×32 0.91″ i2c model. The OLED is soldered directly to the back of the board. Reasonably easy to solder if you have good soldering skills. The OLED display is on the bus at address 0x3C (pretty standard for SSD1306 type displays).

Should you not wish to use or install the on board display, I have provided a 4 pin i2c header for remote display or whatever.

There is also a BME/BMP280 sensor option should you want to monitor your gateway’s environment.

The Nano/RAK/PCB can be powered by the common 5V connector or the Nano can be powered separately through the Nano USB port. A jumper on the PCB is provided for this.

The Nano is running Friendly Elec’s supported version of Ubuntu.

The OLED is driven by the Luma OLED library.

Gateway software for “The Things Network” gateway can be found here:

https://github.com/ttn-zh/ic880a-gateway/tree/spi

You will need to edit the start.sh file to change the reset pin for the NanoPi Neo – Pin1

If you use the GPS option, you will also need to change the serial port to ttyS1 in the global_conf.json file.

IMG_0606

Here’s my unmounted board. I recommend you buy the optional NanoPi Neo heatsink.

My board runs at fairly cool. Operating after 3 hours my board was running at about 32 deg C.  (background temp is about 18 deg at the moment).

Eagle Schematic and PCB files can be found here:

https://github.com/pcm52/NanoPi_Neo_RAK831

As always, use at your own risk. It works for me!

 

 

 

 

 

 

 

 

Distractions

Somewhere along the way I decided to build another CNC machine.
This is still work in progress. Of course it had to have DROs.
I plan to have a manual mode on this machine so they should come in handy.

The DRO version used on this machine consists of a separate module for each axis. Each axis uses a 2.2″ OLED 128×32 display and a ATMega328p.cnc4-1

More on the machine later…

cnc4-2

Again, the case is made from 1″ solid aluminium plate. one side is removable to access the USB ports for programming. (I got tired of using FTDI adapters and ICP headers.

cnc4-3

cnc4-4

Each axis has a OLED display board and ATMega328p board.

First – the display board.  The 2.2″ displays come in 4 different colours – Green, Yellow, Blue and white. They are based on the SSD1305 controller chip. The display panel requires 13V and 3.3V for operation. The 13V is provided using a FAN5331 boost regulator and logic level conversion is done by using a 74HC4050. Interface to the display is through SPI.

Previously I had used I2C to communicate with the displays. SPI is a lot faster. The OLED connects with a 0.5mm pitch socket. Difficult to solder 0.5mm with a standard soldering iron. You really need a SMD rework station for this.

The SSD1305 is not supported by the u8glib library at this stage. It is however very similar to the other SSD series chips. You can modify the code to support these quite easily.

More to come.

 

 

Height Gauge

 

HG1

It’s been a while since my last post.
Been busy building up more DROs for friends to install and test.
This has evolved into a number of 1,2 and 3 axis designs with various sized displays.
More on this to come.

I’ve been distracted with the idea of making a digital height gauge using the same magnetic scales. Most of the basic electronics design is covered in my previous posts on DROs with a few exceptions.

The height gauge needed to be battery powered, auto power off and have a simple push on/push off function. I’ve decided on the LTC2954-1 pushbutton on/off controller made by Linear. This device has an enable and kill output. Perfect for this project.

The electronics is powered by a 6V lithium camera battery. A 3.3V LDO regulator is connected to the on/off controller and the Kill input connected to the ATMega328p to allow shutdown after a pre-determined time. Drawing about 6uA (according to datasheet) in power off mode, the LTC2954-1 seems like a good option for this application.

HG3 HG4

The ATMega328p is running at 8MHz loaded with the Arduino 8Mhz boot loader.

Schematic below:

HSchem

As with the DROs described earlier, the magnetic sensor is made up of the AS6511 / LS7366 combination. the LS7366 being read by the ATMega328p on the SPI bus. Also attached to the SPI bus is a 0.91″ SSD1306 based 128×32 pixel OLED display. Current draw is about 30mA. This should give many hours use from the 6V camera battery.

Display zero reset and metric/imperial units switches are connected to the ATMega328p interupt lines with some hardware debouncing.

The code to run this is pretty straight forward but I’m sure someone can improve it. Values and settings could be stored on power off for example. I haven’t bothered with this. I’m using the U8glib display library rather than my OLED library used on the prototype DROs. Mainly because of the extra fonts and the U8glib library now supports more OLED types. I’ll most likely change the DRO code to use U8glib shortly becasue of this.

The ATMega328p sends a kill signal to the on/off controller after 5 minutes to conserve battery power.

Onto the mechcanical side.

I should say now that the accuracy of this unit will be limited by your machining skills and your machines’s ability to bore accurate parallel holes. I had more than one go at making the body and bronze bushes…. Movement in the gauge slides due to sloppy bush fit on the bars, will lead to disappointment….The sensor and electronics will be more accurate than your machining…

HG5

The main body of the gauge is made from a length of 2″ x 1″ (50mmx25mm) aluminium bar. Bronze bushes are installed into the block to run on 16mm and 12mm ground rods. In my case i used good quality silver steel (or drill rod as some of you call it) Again – the bronze bushes MUST be a good fit on these bars. I bored all holes on my milling machine with the stops set left and right. This allowed me to bore the base, body and top all parallel. Brass locking screw on the left of the gauge acts directly on the 12mm bar.

My base is made from a block of cast iron and the scribe made from a piece of 6mm gauge plate (or 01).
My gauge has a range of about 200mm but this can easily be changed by the length of your bars and length of magnetic strip.

The magnetic strip is set into the 16mm bar in a 10mm slot.  From experience, I can say it is best to make the slot run to the end of the bar on at least one end. The AS5311 sensor sits less than 0.5mm above the magnetic strip. The sensor can easily be ripped of the circuit board at the end of the slot if you forget the slot doesn’t go to the end of the bar…ask me how i know this….

HBoard

The PCB layout shown above allows the sensor portion on the left hand side to be ‘snapped’ off the board to allow mounting of the sensor. This can be seen below where the sensor is mount below the main PCB.

HG2

Shown above with the front panel removed. (It’s hard to photograph the OLED display to demonstrate how sharp and bright the display actually is.)

If you decide to make one of these – providing you take care machining, you should end up with a very usable, easy to read height gauge.

Eagle layout files and the code can be found here:- Design files

OLED displays can be purchased here: – buydisplay.com (for the blue display. Also available in white on black but I find the blue on black brighter)

These guys have a good selection of displays. This is where I purchase most of my displays.

 

Ready for testing….

The display housing is to be made from a 1″ thick block of Aluminum.
Shown here ready to be attacked by my Tom Senior M1 mill.

SANYO DIGITAL CAMERA

A few hours and many chips later… this is now complete and mounted on the Taig mill.
Buttons have been recessed into the front panel along with some 3mm clear acrylic to cover the display.

SANYO DIGITAL CAMERA SANYO DIGITAL CAMERA

Ready for testing. (still have that blocky font – still on the list to modify)

Here’s the Taig with it’s new DRO.

SANYO DIGITAL CAMERA

The Taig has a few modifications from standard. Single to 3-phase VSD /motor and ER16 spindle.

Lead screw cover still to be re-installed. This will need some modification due to the installation of X & Y axis sensor mounts shown below.

SANYO DIGITAL CAMERA

The magnetic strips are mounted in 16mm U channel. This provides protection for the strips against swarf/chips.

 

 

 

Prototype 3

More progress on the prototype DRO. Buttons are now working – Axis reset and Measurement toggle.
Also added a startup config option to allow default metric/imperial measurement and reverse axis options.

New board has been designed and back from the PCB house. I have added a header for S/W SPI port and select
lines in case anyone whats to use standard 7-segment displays via MAX7219/MAX7221 drivers.

display-p3 Display-p3-2

The board uses a surface mount TQFP ATMEGA328P. ICP and FTDI headers provided for Bootloader/Prog.
I managed to load the bootloader using either an UNO as a programmer or using a cheap USBASP programmer board.
Both worked. The board is treated as a Arduino Uno and must be set as this in the Arduino ADE for either bootloading or programming via FTDI.

Font still needs updating for the OLED display.

Sensors have been mounted in the aluminium cases I made earlier. I have potted these in epoxy resin and added armoured cable.

The top of the AS5311 sensor sits above the resin and casing by a small amount.

sensor-pot

My small Taig mill will be the first recipient of the DRO. I’ve spent a few days making the mounting brackets for this.
Here’s the Z Axis sensor mounted and ready to go. The magnetic strip is mounted in a 16mm square aluminium U channel.

I’m in the process of mounting the X and Y sensors.

Taig-dro-1

Next step is to mount the display board. For this I plan to mill the case from a solid block of one inch thick aluminium.

Prototype 2

So the first batch of PCBs for the DRO display have arrived. Looking good.
First problem, I made the holes too small for the header pins on the Nano and OLED display.
Drilling will remove the thru-hole plate so since this is a prototype, I will use strip sockets with smaller pins to mount these.

I plan to use a SMD ATMega328p TQFP chip on the final board. the final board will have a FTDI and ICP header.
I also purchased a TQFP 32pin socket to allow me to pre program the chips.

Still waiting on some voltage regulators and shottky diodes to complete but have enough bits to make a start.
Hooked up three sensor boards, the Nano and the OLED. modified my single axis code to support three.
Seems to be working well. Basic code fits in about 13k program space. No noticable lag in display update.
The encoder read happens every 50mS and the Arduino seems to cope with this.

IMG_0165IMG_0166

Remember that most of the work is done by the LS7366 Encoder/counters. The LS7366’s sole purpose being to count the pulses from the AS5311 encoders and store the count. All the Arduino needs to do is retrieve the count over the SPI bus and display to the OLED in either metric or imperial. No interrupts needed…. 

Next step is to add the zero and metric/Imp switches for each axis (6 switches). I’m planning on doing this with one analog input and six 1k ohm resistors in a ladder configuration. So here’s the schematic with the planned switches. The switch portion being untested so far.

2.4-Display

The display font is a scaled 5×7 pixel standard font. As shown in the photos, it is scaled twice size so looks a bit blocky. I’ll look at adding some better looking fonts so the layout looks better. One I confirm the switch design is working, I will re-design to use a smaller PCB with a SMD ATMega328p. I’ll also add a jumper to select the default measurement unit at power on. Currently this is set to imperial but can be changed on any axis by the push buttons.

These OLED displays are really impressive. I originally planned to use standard MAX7221 driven seven segment displays as seen in the first prototype but after using these OLEDs, I can’t see the point. I’ll include a 3 channel SPI header on the final board for anyone that wants to stick with seven segments, but OLEDs are now my favourite.

For those who are keen on the seven segments, here’s the schematic.

7seg

One for each axis. Use either MAX7219 or MAX7221. Datasheet is online.

Anodizing

Sensor case looks like a good candidate for some home anodising….(or Anodizing if you are American)
You can do this pretty easily without acid and get pretty good results.
I’m in New Zealand… The nice caring authorities here don’t trust people like me with sulphuric acid needed for the usual methods. It’s not that easy to buy here. Never mind.. there are alternatives.

Sodium Bisulphate – commonly used to lower the PH of swimming pools. This is a salt of Sulphuric acid and for my purpose, will work fine.  Usual disclaimers here… I’m not responsible for any damage you do to yourself etc if you attempt this. Use common sense when using these chemicals.  This works for me.

Here’s how I do it.

First I make sure the aluminium is really clean and all those machining marks have been taken out. And when you think it’s really clean, clean it again.  I like to etch the aluminium in some Sodium hydroxide (NAOH, Drain cleaner) for a few minutes. A few teaspoons in a 1/2 litre of water is all you really need.  Sodium Hydroxide is nasty stuff on skin and eyes….cover them. I don’t soak it longer than about 5 minutes. This eats aluminium nicely.

sensor5
I wash in water taking care not to touch with my oily hands….

I use a piece of aluminium about 120mmx100mmx6mm thick for the cathode. I use a low current car battery charger. Mine is 2200ma capacity. This is more than enough for such small objects and finally a Sodium Bisulphate solution. I use about 1 part NaHSO4 to 4 parts water by weight. So about 200g disolved in 800ml water. Negative to the cathode, positive to the nicely cleaned case connected with some aluminium wire. Place them a few inches apart and let it bubble away for anything from 1 to 2 hours. Small hydrogen bubbles will be seen bubbling up from the cathode. Best done outside since hydrogen is of course flammable…..Here’s one of the cases being anodised. Current is about 250mA. (bubbles not really visible in the photo)

sensor7

So I have my newly anodised case. Time to dye it.
I’ve experimented with a number of dyes/inks. I’ve had varying degrees of success with black acrylic dyes and inks. Most of these give a blue or purple colour on aluminium. So black acrylic ink gives me any colour between purple and black depending on concentration. A bit of experimmentation is required here. For this, I’m using some ‘Pebeo colorex’ black ink.

I now use the ink non diluted. I apply it with a small brush. Providing your anodizing process has worked properly, this should soak up the ink almost instantly. If you can still see the metal after applying the ink, the aluminium is either not clean enough or hasn’t been anodized long enough. I then boil it for about 20 minutes in boiling water to seal.

You can remove the anodised coating if necessary by soaking it in Sodium Hydroxide again.

sensor6

Done.