Saturday, 28 March 2020

Coronovirus lockdown- Second Week - Retrospective preparations

This  that follows is an expansion on an email that I sent to friends in Canada where the situation has not yet got to the state that it is in Britian. I expect it to grow as I think of more things.

Monday 9 March  Self - Isolation started
Friday 20 March Schools Closed
Monday 23 March Lockdown - Not allowed off property.


Belong to a Library and see what they have in ebooks, audiobooks and e-magazines

Tinned foods keeps well. It keeps even longer if you have a crap can opener.

Think about what decorating needs doing in the house and get in the paint, brushes, masking tape etc. 

There are going to be a lot of long haired people around when this is over.  Can you get some clippers so your partner can practice on you? 

Time to dig for Victory and plant a garden? Get seeds and compost and plant feed and fertiliser.

Get yourself in shape for it: Glasses checked, teeth examined etc. I broke a tooth yesterday and have got a fixing kit so am going to do some home repairs. 

Get a new computer while you can get it delivered.

Stock up on some powdered milk in case the real stuff is not available. 

The instructions are to wash your hands for at least 20 seconds every time. My hands have got very dry and are cracking up, so I would suggest getting in some hand cream. 

On the basis that you don't know what you will be able to get if you are locked in, here are some ideas:
Washing machine powder,

As I mentioned, with extreme handwashing my hands are cracking up, especially as I have to wash them after painting. 

Maybe get some rubber gloves in. I use them all the time anyway. 

I see that the social distancing of 2 Metres is not sufficient according to a Harvard or MIT study.

I should have got in more paintprushes, they don't last for long, especially when you are only doing a bit a day and cleaning them every time. 

and - Household glue - I use a fair bit of contact cement and my tube is nearly empty. I won't be able to get any more because all the hardware stores are closed for the duration.

One more thought. My Linux User Group message board suggested that we sign up for folding@home So most of us have. Let your computer keep working while you are gardening/painting.

Also I was asked this morning how long  a car could be left without use. The best advice seems to be to take it for a 10 mile run every two weeks just to charge the battery and make sure the tyres don't get any flat spots. 




Tuesday, 24 March 2020

Lockdown - March 2020

24 March 2020: I have a note beside me that spells out the four steps of personal response to the Coronovirus pandemic.
1. Social Distancing
2. Social Isolation
3. House Arrest
4. Lockdown.

For the last week since we went to our coffee morning and only very few people were there, we have been practicing Social Isolation. It is very difficult to avoid touching something that someone else has touched, such as the food that Tesco delivers, and the post, and when Lian next door gave us some milk. When you read that the virus can exist for 72 hours (3 days) on hard plastic or metal, and for a few hours on cardboard and paper, you want to leave any post that is delivered until the evening to read.

For the past week we have been driving out and having our tea/coffee from a flask somewhere is the countryside, where we don't see anyone else. Now we are in lockdown and only allowed out of the property once a day for exercise. It will be interesting to see how that works. Ross next door started a new career yesterday with his coffee van. Dave (his father)  said that he had spreadsheet out all the figures before he bought into it, but this lockdown is going to blow a big hole in that.

I made a schedule of painting for the woodwork around the house. This is the second day and it is already blown. I painted the downstairs bathroom yesterday instead of the upstairs one as per my schedule, and today I am putting it back together and preparing the stairs for tomorrows painting.

Friday and on Thursday I painted one side of the staircase. Masking tape still there. I need a new brush.

We'll see.  I have a number of other tasks on a list that keeps on growing.






Saturday, 1 February 2020

Raspberry Pi Ad-Hoc wireless configuration

If you want to use the Raspberry Pi wirelessly without having an access point, you have to configure the Pi as its own Access Point. This is how I did it with links to information at the end.

------------
Will your Wireless dongle work in this mode? Luckily the R-pi Zero W does, but my Aqprox dongles don't.  This tells you how to find out, and also how to configure it. https://wiki.archlinux.org/index.php/software_access_point

------------
Most dongles will  work directly with the R-Pi, but my Zyxel one doesn't any more under Raspbian Buster.   It was necessary to  sudo apt-get install firmware-zd1211.

2022-08-28 New R-Pi OS. Cannot find this package.

------------
 Initial Wireless configuration [under Buster] to connect to my home network

in /etc/ the file dhcpcd.conf:  my changes are in italics

# A sample configuration for dhcpcd.
# See dhcpcd.conf(5) for details.

# Allow users of this group to interact with dhcpcd via the control socket.
#controlgroup wheel

# Inform the DHCP server of our hostname for DDNS.
raspberry_pi

# Use the hardware address of the interface for the Client ID.
clientid
# or
# Use the same DUID + IAID as set in DHCPv6 for DHCPv4 ClientID as per RFC4361.
# Some non-RFC compliant DHCP servers do not reply with this set.
# In this case, comment out duid and enable clientid above.
#duid

# Persist interface configuration when dhcpcd exits.
persistent

# Rapid commit support.
# Safe to enable by default because it requires the equivalent option set
# on the server to actually work.
option rapid_commit

# A list of options to request from the DHCP server.
option domain_name_servers, domain_name, domain_search, host_name
option classless_static_routes
# Most distributions have NTP support.
option ntp_servers
# Respect the network MTU. This is applied to DHCP routes.
option interface_mtu

# A ServerID is required by RFC2131.
require dhcp_server_identifier

# Generate Stable Private IPv6 Addresses instead of hardware based ones
# slaac private

# Example static IP configuration:
interface eth0
static ip_address=192.168.1.9/27
static routers=192.168.1.1
static domain_name_servers=192.168.011 8.8.8.8

interface wlan0
static ip_address=192.168.1.8/27
static routers=192.168.1.1
static domain_name_servers=192.168.1.1  8.8.8.8

# It is possible to fall back to a static IP if DHCP fails:
# define static profile
#profile static_eth0
#static ip_address=192.168.1.23/24
#static routers=192.168.1.1
#static domain_name_servers=192.168.1.1

# fallback to static profile on eth0
#interface eth0
#fallback static_eth0

-- -- --
in /etc/wpa_supplicant/wpa_supplicant.conf

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=GB

network={
ssid="bmth-upstairs"
psk="password"
# proto=RSN
key_mgmt=WPA-PSK
# pairwise=TKIP
# auth_alg=OPEN
}


---------- 
Preparing for Ad-hoc operation  (taken from Robot-7-flask.doc page 5)
[connect via Ethernet or Wifi]
programs to load: Hostapd, dnsmasq

sudo apt-get install dnsmasq hostapd    

stopped dnsmasq and hostapd, and rebooted. 


sudo systemctl stop dnsmasq
sudo systemctl stop hostapd

Edit dhcpcd.conf as described in the link above to assign a newIP address for the AP. 
This bit then looks like:


interface wlan0
    static ip_address=192.168.4.1/24
    nohook wpa_supplicant

Wpa_supplicant.conf now looks like this:

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=GB

network={
ssid="rc-car"
psk="Ashmeads"
key_mgmt=WPA-PSK
}



restart the dhcpcd daemon.

edit the dnsmasq file to set the dhcp ranges. 

Continue following the instructions in the link to set up other parameters. 

My file /etc/hostapd/hostapd.conf  looks like this:

interface=wlan0
driver=nl80211
ssid=rc-car
hw_mode=g
channel=7
wmm_enabled=0
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=Ashmeads
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP


----------  
Use Wifi analyser and fing on a tablet to see if the SSID Rc-car is present. 

---------- 

This is a part that was omitted from the Raspberry Pi documentation :
We still have to show the system the location of the configuration file:
sudo nano /etc/default/hostapd
In this file, track down the line that says #DAEMON_CONF=”” – delete that # and put the path to our config file in the quotes, so that it looks like this:

DAEMON_CONF="/etc/hostapd/hostapd.conf"
I got this from  https://thepi.io/how-to-use-your-raspberry-pi-as-a-wireless-access-point/
And don't forget to edit rc.local to change the IP address used by Flask.
LINKS

https://wiki.archlinux.org/index.php/software_access_point

To set up  Access Point:





Sunday, 26 January 2020

RC Car Steering with PWM and more about Servos

At the end of https://madsmaddad.blogspot.com/2019/07/rc-car-number-3.html I mentioned that I was going to try this. I said that I had binned CAr #2, but it was actually car #1, and #2 was in a box hidden away. This post is about car #2.

After proving that I could use a Raspberry Pi to drive a Servo, I decided to change out the motor drive steering of this car for a servo and adjust the software accordingly to drive it.   The initial video that explained it all was at https://www.youtube.com/watch?v=N5QmZ92uvUo and he explains teh concepts behind PWM control with it. A simpler explanation is at https://www.youtube.com/watch?v=xHDT4CwjUQE

I have got it working but have not yet taken it out on the road because the R-Pi is sitting beside the car like a heart monitor.


Here is the servo in position for steering car I drilled a hole in the steering arm for the servo arm to go through, rather than trying anything fancy like rods as usually seen in RC airplane controls.  The Servo is stuck in place courtesy of my hot glue gun. At the top right of the picture is the original steering motor just pushed out of place. 



Raspberry Pi Model B connected to the Car. All of the pins connected to the second row of the GPIO except for a yellow ground pin.
Pin 2  +5v to Servo Black wire
Pin 6   gnd to Servo Reddish wire
pin 12 to  IC socket pin 11
Pin 16 to IC socket pin 10
Pin 18  PWM to Servo Yellow wire
Pin 9   gnd to IC socket pin 2 (gnd)

See this previous writeup for the IC pinouts on the control board. https://madsmaddad.blogspot.com/2018/03/second-rc-car.html




This shows the IC socket replacing the receiver IC on the driver board. The black connector card connects all the driver outputs to the relevant motor and also brings in the power for the board from the battery pack at the bottom of the picture.

SOFTWARE

This uses  the Flask setup with the Wifi setup as an Access Point so that I can work direct to it from my tablet.

There are three programs required.

Shell script:  Incorporate this in rc.local to make it run at startup,
export FLASK_APP=/home/pi/rc-car/app.py
flask run --host=192.168.1.8

Set IP address to correct address for the Access Point setup.

HTML:

<!DOCTYPE html>

<! developed using https://www.w3schools.com/css/css_grid.asp for the grid 30 Jan2019

<html>
<head>
<title>RC-Car with Flask & PWM steering 20-1-2020</title>
<style>
.grid-container {
  display: grid;
  grid-template-columns: auto auto auto auto;
  background-color: #ffffff;
  padding: 10px;
  grid-column-gap: 20px;
  grid-row-gap: 50px;
}
.grid-item {
  background-color: rgba(255, 255, 255, 0.8);
  border: 3px solid rgba(0, 0, 0, 0.8);
  padding: 20px;
  font-size: 50px;
  text-align: center;
}
</style>
</head>
<body>

<h1 align="center">RC-Car with Flask & PWM 20-1-2020</h1>


<div class="grid-container">
  <div class="grid-item"></div>
  <div class="grid-item"></div>
  <div class="grid-item">
    <a href="/motor-forwards/" data-toggle="tooltip" title="Forward" class="btn btn-success">Forward</a>
    </div>
   <div class="grid-item"></div>

  <div class="grid-item">
    <a href="/motor-left/" data-toggle="tooltip" title="Left-Left-Left!" class="btn btn-success">Turn Left</a>
    </div>
    <div class="grid-item">
    <a href="/turn-center/" data-toggle="tooltip" title="Left-Left-Left!" class="btn btn-success">Center</a>
    </div>
  <div class="grid-item">
    <a href="/motor-stop/" data-toggle="tooltip" title="Stop Motors"  class="btn btn-danger">STOP</a>
    </div>
  <div class="grid-item">
     <a href="/motor-right/" data-toggle="tooltip" title="Turn right!" class="btn btn-success">Turn Right</a>
    </div>
  <div class="grid-item"></div>
  <div class="grid-item"></div>
  <div class="grid-item">
    <a href="/motor-backwards/" data-toggle="tooltip" title="Reverse!"  class="btn btn-warning">Backward</a>
    </div>
  <div class="grid-item"></div>
</div>

</body>
</html>


Note that I have used W3Schools for a lot of help in getting my HTML correct. Some of the bits in each line referencing the contents of a box are possibly redundant. They were there in the code where I pinched the stuff.  [ see below for simplified stuff].

PYTHON:

# 2020-1-20 Modifications to drive steering using a servo and PWM.  Because I
# don't know if gpiozero and RPi.GPIO can work together I'll remove the GPIOzero and motor
# command.  motor = Motor(forward=12, backward=16)
# look at ancient code for motor handling.
#  2018-04-05 Modified from Les Pounder program to handle two motors
# one for steering and one for motion
# steering is Left = 10, right = 11
# changing it trying to add Turn for motor control
# 2018-10-31 changing toggle LED to stop motors

from flask import Flask, render_template
from time import sleep
import RPi.GPIO as GPIO

#Set GPIO Numbering mode

GPIO.setmode(GPIO.BOARD)

# set pins for motor control

GPIO.setup(12,GPIO.OUT)
GPIO.setup(16,GPIO.OUT)

# set pin 18 as Output for Servo Steering
GPIO.setup(18,GPIO.OUT)
servo_st = GPIO.PWM(18,50)

#start PWM running on servo, init value 0 (pulse off)
servo_st.start(0)
# servo runs from duty cycle 2 to duty cycle 12, 7 being central position  for servo used in youtube demo.
# define variable duty
duty = 2

app = Flask(__name__)

@app.route('/')
def index():
    return render_template('index.html')

@app.route('/motor-stop/')
def on():
    GPIO.output(12,False)
    GPIO.output(16,False)
    return render_template('index.html')

@app.route('/motor-forwards/')
def motorforwards():
    GPIO.output(12,True)
    GPIO.output(16,False)
    return render_template('index.html')

@app.route('/motor-backwards/')
def motorbackwards():
    GPIO.output(12,False)
    GPIO.output(16,True)
    return render_template('index.html')

@app.route('/motor-left/')
def motorleft():
    duty = 2
    servo_st.start(duty)
    sleep(1.3)
    servo_st.ChangeDutyCycle(0)
    return render_template('index.html')

@app.route('/turn-center/')
def centersteering():
    duty = 7
    servo_st.start(duty)
    sleep(0.3)
    servo_st.ChangeDutyCycle(0)
    return render_template('index.html')

@app.route('/motor-right/')
def motorright():
    duty = 15
    servo_st.start(duty)
    sleep(0.3)
    servo_st.ChangeDutyCycle(0)
    return render_template('index.html')

if __name__ == '__main__':
    app.run(debug=True, host='0.0.0.0')


The major changes in this, other than PWM operation, is the change to GPIO Board numbering rather than GPIO Name numbering.  Also I stopped using GPIOzero, so have reverted to direct control of pins in the software. I like this better. Comments can be used to explain functions that are not clear.


Questions: I am happy to answer them, but they may be already answered in previous posts.

27/1/2020  corrections and simplifications
The  line
 <a href="/motor-forwards/" data-toggle="tooltip" title="Forward" class="btn btn-success">Forward</a>

can be simplified by removing things that don't serve any purpose in this case. It becomes:
 <a href="/motor-forwards/" >Forward</a>


SERVOS

I was given a box of Servos and after having problems with the one that I had put in the car, I went through them plugging them into the Raspberry Pi.

Four of them totally didn't work and caused the R-Pi to shut down.  These were all small ones without labels.

Some of them partially worked.

Here is a breakdown of what happened. The software is set to duty cycle 2 for a Left turn, 7 for a centre position, and 15 for a right turn. I noticed that in some cases the servo shaft turned CCW when I expected CW, and am now confused as to which is left and right.

Device                                               Left               Centre           Right
small unit with black arm.                   x                     ?                    ?

Small unit with white arm                  -90                    0                 +90 (CW)

Digifleet FPS-20                                 -60                    0                 +60

Digifleet FPS-30   dead kills Pi.

Aristocraft HS-100                            -90                increments              increments
'increments' possibly means that I have to extend the range. needs testing

GWS Mini STD                                +90                    0                  -90

Tower Pro Airplane 99                            iffy, slow to respond

Small Black with arm                       +110             no response         -100

Black, short wires                            +110                                          -90

Digifleet FPS33 (2)       dead

Black with black arm.           dead

Powermax Skyranger 5 white-X arm      +75                steps                           -70

Steps/increments probably means that I have to expand the range from 2-7-15.

Another bothersome feature of these servos is that the arms, or whatever the proper term for them is, are different sizes and shapes so are not transferrable from one unit to another. Most are splined, but some are square.

2020-02-08  See https://en.wikipedia.org/wiki/Servo_control

It is not duty cycle that is important, it is pulse width, generally between 1msec to 2 msec wide.
Now I am using a value of duty 2-7-12  with a pulse rate of 50 Hertz.


Also:
https://learn.adafruit.com/adafruit-raspberry-pi-lesson-9-controlling-a-dc-motor/software

and

https://github.com/sarfata/pi-blaster








Tuesday, 14 January 2020

resolving Humax 9150T PVR problems

Initial status  Pre-November 2019
UPSTAIRS
PVR1 sn=...00617                      HD = ...4390
DOWNSTAIRS
PVR2 sn=...01135                      HD = ...0465
------------

22/11 Swapped HD's
- Schedule went with PVR, not HD
- channels selected with PVR, not HD

20/12
 Downstairs  00617 PVR with 0465 disk
HW  Rev 1.0
S/W  1.00.26
Loader  a4.39
Sys ID 3024.0000

UPSTAIRS  01135 PVR 4390 disk
HW  Rev 1.0
S/W  1.00.26
Loader  a4.37      *** only difference
Sys ID 3024.0000

--------------
Skipping occurs on downstairs PVR Now
but only on recently recorded items
Skipping no longer occuring Upstairs.
Skipping defined as playback jumping forward nearly a minute. able to play 'jumped' part if  I rewind to just after the skip started.  The skip is repeateable at the same point always. It seems to occur randomly in the things recorded.

Hypothesis: It is the recording on PVR 00617 that lays down the condition that causes the skip to occur.

What I may do is test whether I can view recording pulled up to PC on my tablet and if so, swap DOWNSTAIRS HD for the spare one that I have.  15-1-20 Can play recording  on tablet.

15-1-20  UPSTAIRS skipping occured once on 1hr program at about min 56

Dug out other HD sn ....6920






Wednesday, 4 December 2019

Raspberry Pi to replace DVR

As our Humax 9150T DVRs are exhibiting some funny characterisitics, I thought that I would see what I could do with my Raspberry Pi. At the DLUG computer club the other night, Kodi was suggested as probably the best software for this. https://kodi.wiki/view/HOW-TO:Install_Kodi_on_Raspberry_Pi

Ia getting together the bits. I was going to use my 160GB Sata Hard disk, but I don't have a USB converter for it.  I am going to use a 40GB IDE disk with my IDE to USB converter. I have my freecom DVB TV stick if that can be used, and the R-Pi bodel B is available, or maybe the Pi-zeroW. I have a seven port USB hub which may be up to the job - That we will see.

Step one - download the software and get it working.
Initially it wouldn't connect by Ethernet, so I started it on WiFi and it connected. I have updated and upgraded the Raspian Buster system, and now am installing Kodi.

Have attached 40G IDE disk via USB, and restarted R-Pi.

From Kodi Wiki page, I cannot find if I can run Kodi via SSH. It seems to want a big screen and a remote control for all operations.

It's not simple - I can't be bothered.




Sunday, 15 September 2019

Upgrading an Android OS

My Argos Bush android tablet is running Android 6.0  which is Build Number MRA58K@ARCHOS.20160617.013735.Catalpa.

I have recently tried to install a couple of Apps and been told that they were not compatible with my tablet.

Can I rebuild a later Android OS for my tablet?                                                   15/9/2019

The Archos site is no use: https://www.archos.com/gb/support/downloads.html?type=tab

https://www.androidauthority.com/build-custom-android-rom-720453/
The two things that I would need help obtaining:
Grab the source – This is an easy step, however it takes a long time. For me it took over 24 hours. Such a large download only happens once, further syncing with the main source tree will be incremental.
Obtain proprietary binaries – The binary drivers should be unpacked in your working directory.


https://www.youtube.com/watch?v=99LUjX63LhU

https://www.youtube.com/watch?v=1pAr5VzpxyY

17/9/19 emailed Archos:
This Android Tablet is running Android 6.0 and I am now finding Apps that won't run on it. How can I upgrade it to a higher version of Android?
I am happy to try and build the OS myself if given the source and binaries neede, and possibly some instruction.

This would lead to the question - How to export/backup the current OS before attempting any updates, in case of failure.

Thank You, Peter Merchant

21/9/19 No response from them yet, but look what I found:
https://source.android.com/
This will be quite a learning experience

2/10/19 Suggestion from LUG www.xda-developers.com  which is on topic but only seems to cater for popular devices.