The TEC-1D Micro Computer

 

Tec-1-computerOver Christmas while randomly scrolling through my Twitter feed I saw some discussion about the TEC-1 computer. This is a single-board kit dating from the early80s based around the Z80. Instructions on how to build it were published in the computer Australian hobbyist electronics magazine Talking Electronics. The Magazine only ran for 15 issues which is a pity as it had the idea of giving away a blank PCBs for one of the projects featured with every issue and did not have any advertising!TalkingE iss 10 cover

Anyway digging around to find out a bit more about the TEC-1 I discovered that a retro computer club in Australia had got permission to reproduce the TEC-1 PCBs and that there were a few left on eBay. Also amazingly although the magazine only ran for a limited time Talking Electronics as a webshop for kits is still up and running and while the kit for the Tec 1 is no longer available you can download pdf’s of all the magazines. 

Given that the Z80 was my introduction to assembly language coding I decided this would be a great early 2019 project to tackle along side my other Raspberry Pi and Arduino activities. So a month or so later I have the bare board and have started to source the parts for it.

Scarily I have managed to find quite a number of the parts in my stocks of bits from long forgotten projects. The rest I have been able to find through eBay and people like Bitsbox.

Trying different switches

I am looking forward to start the build in earnest this week and hopefully post a blog update with some parts soldered on next weekend !

Posted in Uncategorized | Leave a comment

Re-purposed PiMuxClock

IMG_1711It’s been a good while since I have posted any blog updates, no excuse just distracted by life in general. This is quick weekend project at my daughters request. Concerned that some of the plants in her student flat would struggle in the cooler weather she requested a temperature display. Looking around the options I remembered my first Kickstarter was also set up to display temperature along with time. So a quick hack to remove the time element, change the board mounted DS18B20 sensor to cabled version and add max / min logging and it’s ready to take down to her.

Using it with a Pi2B is a bit of overkill but I am gradually changing out existing projects to Pi3s so have a few ‘spare’ hanging around.

IMG_1701

The hardest bit was stopping one of the cats helping – I just managed to apprehend Pinky as she ran off with an ESP8266 board which clearly looked like a mouse to her !

I’m guessing the next request will be to add some form of push notification, if the temperature drops to a certain point but that is for another day.

The code is available on my GitHub site if you are interested.

IMG_1705

Posted in Uncategorized | Tagged , , | Leave a comment

6 Years of Pi – Then and Now

Ok so in addition to losing about 5st (31kg) over the last 6 years RaspberyPi’s have really reignited electronics as a hobby. So for a 6th birthday post I thought I would have a dig around and see what my oldest still ‘working’ project was. I remember I got 2 Pi B early on – one was used for a chicken water heating project and eventually suffering Chiltern-20131201-00348terminal water damage when the enclosure leaked  (to date this is the only Pi of in excess of 30 I have killed). So continuing the hunt I found the news reader Pi I built for my wife based around an article in one of the early Pi magazines. Amazingly it is still working. I plugged it into a monitor just to remember

new box screenwhat the old LX  GUI looked like!

news box

As you can see it’s warning us about Storm Emma.

 

 

 

Going on from the Pi’s  it’s worth recognizing that somewhere down the line I have gained a workable knowledge of :-

  • Python
  • Arduino’s that oddly I had never used before – thanks to the RasPiO® Duino for getting me into this.
  • BBC microbits

Oh yes and run 3 successful kick-starters.

This year things are a little quiet on maker front mainly because out of a shear madness I have signed up to run the London Marathon, training for which is taking up a lot of time a weekends. The charity I am raising money for is the MS Trust. I picked the MS Trust having heard about the support they gave the mother of a colleague. They are not a big charity, so sponsorship money raised through events like this is really important to them. The Trust focuses on helping people live well with MS, helping them to receive the best possible care and the highest quality information. Over 100,000 people in the UK as diagnosed with MS, which remains the most common cause of neurological disability in young adults. Because diagnosis is usually in their 20s and 30s, the impact on the individual and their family if life changing and life-long.

The link to my Virgin just giving page is https://uk.virginmoneygiving.com/DavidMSaul

 

 

 

 

Posted in Uncategorized | Tagged , , | Leave a comment

TF WordClock S/W Updated

IMG_2102Just a quick post to say I have updated the TF Wordclock s/w to rev 5, the existing rev 3 s/w was not working reliably with the Nov29 2017 Raspbian update, in truth it had been on borrowed time since early 2017 when there was a major change to the Max7219 library. This did not offer an upgrade path so the TF was stuck with using a depreciated version  of the library.

Luckily the library author, Richard Hull suggested a way I could implement required functionality with the updated library –  now called luma.led_matrix.

This has required quite an extensive change to the TF with English, French and Dutch Wordclock versions  now available – unfortunately Latin is not currently supported.

If you want / or need to move to the rev 5 code you should do this from a clean installation of Raspbain.

Staying with the rev 3 code this is fine but be careful not to do an apt-upgrade as you will almost certainly find your TF will stop working.

The Nano version is not affected by this change.

Posted in Uncategorized | Leave a comment

Standalone Video display with a Raspberry Pi

IMG_0785A couple of weeks ago my wife arrived back from Lindengate a local mental health gardening charity she volunteers at with an old PC monitor and asked if I could set it up to continuously display a series of videos, she had created to highlight the charities work. Typically the when was the following week and the where was a local doctors surgery. The when meant I was limited to ‘in stock’ parts and the where meant untended operation in a public place. I knew there were various existing instructions for doing this sort of thing with a Raspberry Pi and after a bit of internet searching found an article for a video looper on the Adafruit website which simply automatically plays video files from memory stick  inserted into one of the Pi’s USB sockets. I tried this out on a Pi3 and it ticked all the boxes in terms of play back and ease of use, so that was the s/w sorted.IMG_0782

Looking at where display was going  it needed not only to start-up without the user having to do anything but also not look too much like a DIY project built out of parts from my garage one night !  To get the size down I moved to a Pi Zero, with a VGA converter dongle [VGA being the only input available on the monitor] and a short micro USB to ‘type A’ converter lead. This all worked fine but did leave the perennial problem of how to safely turn the Pi off. Given a keyboard or VNC connection was out of the question I opted to fit a on/off switch to the Reset / run connector on the Pi. This way we could include a clear instruction to set this switch before removing the power. Now on paper I know this is not the best way to power down a Pi but in practice I have found it does seem to avoid corrupting the SD card.

IMG_0700Once tested this was all packaged in a small box  left over from another project. This I was able to mount on to the back of the monitor using one of the VESA mounting points on the back of the screen. The end result looked really quite professional with no unnecessary bits of wire hanging out !

IMG_0786

 

 

So far the display has been put to good use in the doctors surgery and at the charities Autumn fair. The total parts cost excluding the monitor was around £32 using a Zero 1.3

Link to the Lindengate Facebook page

Posted in Uncategorized | Tagged , , | 1 Comment

BBC micro:bit Scrolling display

IMG_0682(1)Looking at my distributed BBC micro:bit clock I got to thinking, could I make a display screen using a number of micro:bits, using the radio functionality to update the screens ?To see if the basic timing would work I created some very rudimentary code on 4 micro:bits. Initially I tried to use the ‘display.scroll’ function. After much fiddling I did get this to work after a fashion, but in truth it looked rubbish. On the point of giving up I thought I would see what it would look like using the ‘display.show’ function. This produced a much more readable result so I decided IMG_0694to go on and develop some ‘proper code’. I had previously looked at with David Whale’s python ‘microbit’ module and this seemed a great way to get the text strings ‘into’ the micro:bit. which solved the problem of how to front end the display. The remaining s/w built used in my distributed micro:bit clock.

Software

The software for the scrolling display has 3 elements;
[the pink x in the names indicates the rev number where I plan to develop the s/w further]

1) The micro:bit display node application [node_scroll_showx.py]

This is a simple python app you need to download on to each of the micro:bits that form the message display. The s/w for each micro:bit is identical. The software listens using using the radio function for any messages addressed to it coming from the gateway micro:bit displaying any valid character using the display.show function. It will keep displaying this until it receives a new valid message. The address of each display node is set the first time the s/w is run (normally this would be directly after download). The micro:bit will display a ‘?’, to show the address needs to be configured. The address is set using button ‘a’ and once correct store it using button ‘b’ – the address is stored in non volatile memory. On subsequent restarts it will be automatically selected, but you can change it by holding down button ‘a’ and resetting the micro:bit.

2) the micro:bit scroll display gateway application [gate_scroll_rx.py]

This is a somewhat more complex python app, performing 4 functions receiving messages from the Pi, creating the scroll effect, segmenting the message and finally transmitting the individual character information to the display node micro:bits.

Information is received from the Pi via a USB connection, this is described further in the RPi gateway application section.

Message format

The basic message format is <type><message>. ‘type’ is either ‘1’ to display a static message or ‘2’ for a scrolling message. So for examples if the gateway micro:bit receives the following message ‘2HELLO WORLD’ you would see ‘HELLO WORLD’ scrolled across the display node micro:bits. This would be repeated until the next message is received.
Static messages are automatically truncated to the number of characters in the display. If you want to see how the scroll process works the best way is to look at the python code but in simple terms I create a shift register in s/w and simply cycle it.

Setting the number of nodes

The gateway micro:bit needs to know how many display nodes it is talking to, this is set the first time the s/w is run (normally this would be directly after download). The gateway micro:bit will display a ‘D’, to show the number of nodes needs to be configured. This is set using button ‘a’ and once correct stored using button ‘b’ – the number is stored in non volatile memory. On subsequent restarts it will be automatically selected, but you and change it by holding down button ‘a’ and resetting the micro:bit.

3) The RPi gateway applications

The gateway application running on the RaspberryPi communicates with the micro:bit gateway via a USB connection, using a python module called ‘microbit’ (thanks to David Whale) for telling me about this – here is a link to his github. To date I have just written a few demo applications using the microbit module. When you first run an application using the microbit module it will take you through a setup process to allow the s/w to identify USB connection name. It will attempt to use this name for future connections. If this fails you will need to go through the identification process again, you may also need to restart the Raspberry Pi. The 4 apps I have currently uploaded on to GitHub are;

  • A simple program to display a user inputted string,  [gateway1.py]
  • A clock demo [gatewaytime_date.py]
  • A Tweepy application which will scroll any messages with a specific prefix. [tweepy8a_microbitxx.py]
  • A basic GUI that allows you to scroll / show strings or display time in a range of formats [scroll_GUIx.pyw]

The GUI app is my first real attempt to use Tkinter and I am sure I have broken a number of, but it seems to work and was interesting to code

Hardware

One of my goals in developing the scrolling display was to avoid any extra hardware or the need for expensive sockets etc. To get the best effect the node micro:bits need to be mounted in a straight line as close together as possible. The mounting board I used is just a bit of fibre board I had spare. Having worked out the required spacing I drilled a series of 3mm hole, then used 2.5mm stand-offs and screws to mount using just the 0v and 3v ‘holes’. Using 3mm img_0697-e1505571864514.jpgholes with 2.5mm screws gave a bit of ‘slop’ to get everything aligned neatly. You can find a copy of the dimensions I drilled to at the end of this post.

Initially I just used individual batteries to power each micro:bit. Once I was happy the with the mechanical arrangement I found a suitably rated 3.3v supply and changed to power the node micro:bits via the GND and 3v pins – if you go down this route you need to be very careful as an error here could end up destroying all the node micro:bits. Also most importantly you have to include a diode on the 3V line.IMG_0671(1)

This stops a micro:bit ‘back powering’ all the others when you are downloading code to it via the USB line – I am guessing the USB supply on the micro:bit is not rated to drive 10 micro:bits ! You can see how it is wired up in the picture below

scroll_block

IMG_0696

Rear wiring detail

IMG_0698

Front face of 10 digit display

MBdim

The dimensions I used for drilling the mounting board

 

You can have a look at some short videos of the scroll display working on my YouTube channel

Initial demo

10 digit display demo

Tweet display demo

 

Posted in Uncategorized | 1 Comment

Distributed BBC micro:bit Clock

IMG_0619The idea for this project came from a tweet by David Whale [@whaleygeek] showing a font he had come up with for the micro:bit that managed to squeeze 2 digits on to the 5×5 led display. I have taken initial clock code he wrote and added functionality to read a Real Time Clock module connected via the I2C port together together with some other bits.

The time display is spread over 3 microbits [ 2 if you don’t want seconds ], these communicate using the radio function in micropython . You can also have a single micro:bit with a scrolling display. There is no limit to the number of slave micro:bits, but do only connect the RTC to a single micro:bit.IMG_0581

The clever bit, [well I think it it is !] is that all the micro:bit’s all run exactly the same code. You configure the display to hours / minutes / seconds or scrolling by connecting the P0-3 lines high. The software automatically identifies if it has the RTC connected to it and if so makes it’self the master synchronizing the other micro:bits every minute.

The whole thing is written in micro-python programmed using MU running on a Raspberry Pi. You can find instructions on how to install the latest version of MU in the micro:bit section of my site.  The code listing is commented so you can sort out which bit does what. If you want to change to code it is worth noting that it basically maxes out the available micro:bit memory as it stands.

IMG_0620Hardware, it is really up to you, I have used small ‘maker’ interface boards I got made to up allow me to mount the micro:bits vertically on a bit 0.1″ matrix board, but you can easily use one of the commercially available breakout boards. The RTC is a DS3231 RTC module. The only other bit I added was a simple 3.3volt PSU using a 78L33 and microUSB adapter board.IMG_0587(1)

if you don’t want to build the power supply you can simply power one of the micro:bits from it’s battery or micro:USB connection and it will feed the others and RTC.

You can download the micropython code and also a basic schematic showing how I connected all the bits from my GitHub https://github.com/DavidMS51/whaley_clock .  (Do make sure you download the latest version of the code)

There is also a short YouTube video of the clock here

IMG_0627

Posted in Uncategorized | 1 Comment

Cheap DIY Weatherproof Pi Camera

IMG_2453Always thinking about useful things I could do with a Raspberry Pi my wife asked me about making a time-lapse camera to record some building work at Lindengate, a local mental health gardening charity she volunteers at. While there are a number of Pi camera weatherproof products in the market the challenge here was to spend as little money as possible. You can see one of the short films my wife created using the camera by following this link to Lindergate’s facebook page.

The detail of the build is follows….

 

From a practical perspective the camera needed to be left unattended for at least 3-4 days at a time, not a problem from a storage perspective but it was an issue in terms of power the site is quite spread out and there was no practical way to get power to the place she wanted to film from.

IMG_0564

The obvious logical choice of electronics was a Pi Zero and Pi camera, then looking around the garage a realised that if I stripped out the internals from a spare security light I could easily attach the pi to the glass window using a ‘zeroview’ I already had – effectively for free. This setup also have the advantage of not looking very interesting as people are used to seeing this sort of security light around.

IMG_2451

Rather than try and fit batteries inside the enclosure I opted for taking out a lead  long enough to get to a separate waterproof box with the power supply in. As you can see in the picture I have soldered the power lines onto the Pi, this was simply because I did not have a long USB to micro-USB cable.

The only other change I made was to include a light dependent resistor [LDR] this is attached between GPIO pins 39 [0V] and 50 [GPIO 21] and is mounted through the zeroview board by cutting a small slot with a needle file. The GPIO 21 line is configured as an input with the weak internal pull up resistor enabled. This creates a potential divider so a low on this pin indicates daytime, a high darkness. This allows me to keep power usage to a minimum by not taking pictures after dark. This setup also avoided the need for any extra components other than the LDR.

 

IMG_0566

There is no accessible wifi on the site so to download the captured pictures I simply plug in a USB wifi dongle to a short micro-USB to socket lead I brought out of the enclosure. Then connect via a laptop running VNC and locally a ‘created’  temporary network using a HooToo Wireless Travel Router.  Again this kept the power down as I could disconnect the dongle when not needed – protecting the USB connection with a plastic bag !

 

IMG_0563I tried a number of different power solutions the simplest being USB battery packs, with a large one I could get about 6 days, but main difficulty I had was that newer ones include a sensing circuit that shut the outputs down if the power drain is below a certain level. So they are fine to run a normal pi 3 but with the zero I found that periodically they would turn off which was not not much use. So going back to the garage I found a car battery, 12V to 5 volt converter and a solar panel from previous ‘projects’. With this combination I have kept the camera powered for over 2 weeks in good weather without a problem. I am doing a bit more work on monitoring the power usage so  I can understand how long it is safe to leave the camera for, a bit better – that will be the subject of later blog I hope.

I kept the s/w really quite simple – you can download a copy of the code from my github.  It is set up to take a picture every 10 minutes, but you can change this. The resulting pictures then stored in a single folder. The software is actually a cut down version of program I use to capture and upload pictures of our chicken run to the net !  It is setup to auto run on power up – you can see how I do this here on my site.

The actual video was created using iMovie on a mac portable but there are a variety of other free and paid for editing packages that will allow you to stitch still photos together to make a film. You can see the results here on Lindergate’s facebook page.

cabin_image_12115707082017

The new cabin mid build

 

 

 

 

Posted in Uncategorized | Tagged | Leave a comment

micro:bit Analog Inputs

IMG_0541(1)For the last few days I have been playing with the micro:bits builtin capability to measure analog voltages on P0, P1 & P2 (you can set up some of the other IO lines as analog inputs but this is a bit of an involved process and best avoided if possible).

** WARNING **  – YOU MUST ENSURE THAT ANY VOLTAGE APPLIED TO THE MICRO:BIT DOES NOT EXCEED THE SUPPLY RAIL [TYPICALLY 3V] DOING SO WILL RESULT IN DAMAGE TO YOUR MICRO:BIT

 

 

By default the analog converter in the micro:bit is referenced to the micro:bit supply rail and is configured for 10 bit operation. Hence the following code;

from microbit import *
a = pin0.read_analog()
print(a)
display.scroll(str(a))

will return 1023 if you connect the 3V & P0 pads together, irrespective of battery condition of if you power via the micro USB connector. For many applications this is fine and using the micro:bits 3V supply as the source voltage for any analog experiments is the best way to minimize risk of damage the the micro:bit.

However if you want to measure a voltage not derived from the micro:bits supply things can become a bit more problematic. It’s fine if you can power the micro:bit from a constant source – for instance a phone mains power adapter, but not so good if you are running from a battery. This because as the ADC (analog to digit converter) reference voltage will drop as the battery discharges resulting in a change to the count value returned. For instance assuming a new set of batteries provides 3V, a 1.5V source on P0 would return 512, but if the battery voltage drops to 2.5V the reading would change to 614 counts. To get around this the ADC in the micro:bit can be configured to reference an internal fixed 1.2V voltage reference. This means the count value will not vary with a changing supply voltage.IMG_0547(1)

In it’s basic setup this would mean a voltage of 1.2V on P0 would give a result of 1023. However 0-1.2V is quite a small range so the ADC circuit includes a configurable ‘pre-scaler’ to help us. Configuring this to 3:1 we get full scale ADC range of 0-3.6V. It is important to note however that the rule of keeping the maximum voltage applied to a micor:bit input pin at or below the supply rail still applies. 

The following code will setup the ADC to use the internal reference on P0 together with a 3:1 pre-scaler.

Code to demo using the micro:bit internal ADC reference 
# based on material and help from Carlos Pereira Atencio https://gist.github.com/microbit-carlos/
# David Saul 2017. Released to the public domain.

from microbit import *

NRF_ADC_BASE = 0x40007000
NRF_ADC_CONFIG = NRF_ADC_BASE + 0x504

# functions used to modify ADC setup
@micropython.asm_thumb
def reg_read(r0):
 ldr(r0, [r0, 0])

@micropython.asm_thumb
def reg_bit_clear(r0, r1):
 ldr(r2, [r0, 0])
 bic(r2, r1)
 str(r2, [r0, 0])
 
 
# change ADC config for pin0

# mbed configured: 10bit, input 1/3, ref 1/3 vdd, enable ADC in AIN4-P0.03-pin0
pin0.read_analog() 
#Set ref voltage to internal ref 1.2V (band gap), set bits 5-6 to 0x00
reg_bit_clear(NRF_ADC_CONFIG, 0x60)
print("ADC config should be 0x100A: {:#010x}".format(reg_read(NRF_ADC_CONFIG)))

#variable definition
vt = 0 # raw / scaled analog value
vf = "0000" # measured voltage as a formatted string 
cal = 352 # calibration variable
# cal is calculated as (Vin / raw count)*10000
while True
 vt = pin0.read_analog()
 print ('raw count = ',vt)
 
 # the following lines of code scale the measured value and derive a
 # string (vf) that equates to it - there are simpler ways to do this
 # but this method avoids the use of floating variables which are very
 # inefficient on cards like the micro:bit
 
 vt = int((vt * cal)/1000) 
 vs = str(vt)
 if vt > 1000:
  vf = vs[0:2]+'.'+vs[2:3] 
 elif vt > 100 :
  vf = vs[0:1]+'.'+vs[1:3]
 elif vt > 10 :
  vf = '0.'+vs
 elif vt > 1 :
  vf = '0.0'+vs
 else :
  vf = '0.000' 
 
 vf = vf+"V"
 print ('Scaled', vf)
 display.scroll(vf)
 
 sleep(2000)

 

link to code on GitHub

The ‘keep to the rail voltage’ is a generally safe but slight simplification of the ADC operating rules. If you are looking to work with source voltages not limited to the micro:bit supply rail there are specific rules you need to be aware of to avoid damaging your micro:bit. A number of discussion threads have been written on these [ probably because it’s not very understandable in the NORDIC chip datasheet ] one example which is ‘relatively’ clear is https://devzone.nordicsemi.com/question/102/what-voltage-range-can-be-measured-with-the-adc/

 

 

 

Posted in Uncategorized | Leave a comment

Meandering Pi and Friends

IMG_0406(1)Over the last couple of months I have spent quite a lot of time experimenting with the BBC micro:bit developing various things including a model train speed controller.  This uses 2 micro:bits one acting as a remote control the other providing a PWM drive to the track. They communicate using a simple 2.4Ghz radio connection builtin to the micro:bit [you sort of get it free with the Bluetooth] .

You can get more details on it’s dedicated project page .

One thing which has been great to discover is that the Raspberry Pi works really well as a desktop environment – to program the micro:bit, either using one of the online tools such as the C/C++ mbed environment or standalone with the micropython ‘mu‘ application.

If you want more information I have created page focused on using the raspberry Pi to program the micro:bit.

IMG_0396(1)

If you haven’t had a play with the micro:bit I really recommend you get one and have a go. They are not a raspberry pi and never will be, but in terms of getting the ‘barrier to programming’ as low possible it is difficult to beat – not least you can be up and doing something in seconds from unwrapping it.

In recognition that I am now talking about more than just Raspberrry Pi’s on this site I am changing the name of the blog to  Meandering Pi and Friends . Hopefully I will be posting to my blog a bit more regularly as well …..

 

Posted in Uncategorized | Tagged , | Leave a comment