Thursday, 26 December 2024

RP 2040 a prime candidate for FORTH

 It seems to me that the Raspberry Pi RP 2040 is a proper candidate for the FORTH programming language.   I am not alone as somebody has already done some versions of the language.

https://wellys.com/posts/rp2040_forth/

https://github.com/kristianwiklund/rp2040-forth

https://hackaday.io/page/11525-multicore-forth-execution-with-multitasking-on-the-rp2040  

(ZeptoForth)

https://wiki.forth-ev.de/doku.php/en:pfw:assemblers_rp2040-assembler

I'll look into these. Then I'll see if I can put an MQTT publisher on one. 

The version of FORTH that I used back in '79-80.

https://www.forth.com/wp-content/uploads/2017/04/microFORTH_on_RCA_COSMAC_05_text.pdf

https://www.forth.com/wp-content/uploads/2017/04/microFORTH_on_RCA_COSMAC_05_source.pdf



Tuesday, 21 May 2024

Lets get car-4 working again ( May 2024) - Still trying November

December 10, 2024: 

Here are two good pages about setting up MQTT and getting Publisher/broker and subscriber working. 

https://bytebeam.io/blog/getting-started-with-mqtt-on-raspberry-pi-using-python/ - Probably better

 as my Subscriber is written in Python. July 2023 Everything except how to set it up to start at boot.


https://diyi0t.com/microcontroller-to-raspberry-pi-wifi-mqtt-communication/  

*** Excellent step-by-step setting up publisher, Broker and subscriber, except for autostart subscriber.

Now I need to find out how to get a  python Subscriber to start at boot.  

This link gives me the best help on what I want to do. 

https://www.codementor.io/@ufuksfk/how-to-run-a-python-script-in-linux-with-systemd-1nh2x3hi0e

------------------------------------------------

Subscriber service now starts, but path to file is now

/home/peterm/pi/mqtt.  The peterm is added because the Pi now needs a user and that is peterm. 


14/12/24 Trying to get AP configured, but failing

https://themakermedic.com/posts/Pi-AP-Mode/ after configuring, tablet cannot find the SSID. 

Will look at this one tomorrow:

https://www.raspberryconnect.com/projects/65-raspberrypi-hotspot-accesspoints/168-raspberry-pi-hotspot-access-point-dhcpcd-method


------------------------------------------------


Alternatively using crontab:

https://tutorials-raspberrypi.com/control-raspberry-pi-robots-via-infrared-remote-control-part-3/

------------------------------------------------------------------------------------

Here is the earlier post about it.

https://www.blogger.com/blog/post/edit/preview/5415560036905179298/8810457589872963960


GPIO PIN            Wire colour 

                                  Car                             Test Rig

6                            White                            Pale yellow

12                          Orange                          White

18                         Red                                Blue

19                        Yellow                            Orange

23                        Green                             Yellow

Now I can swap R-Pis and see if there is a problem with the car one. 

swapped boards, and test rig ran the same, except that after analog left, left LED kept flickering and I couldn't stop it. Another software fault.

Also Red forward LED on at startup. 

----------------------

23/8/2024 

HAve rebuilt software using latest RaspIOS and it is different. 

Looking at this to try and figure out how to configure it.

https://bytebeam.io/blog/getting-started-with-mqtt-on-raspberry-pi-using-python/

Problem installing Paho-mqtt. Need to look into it. 

12/10/24 working through this. Got through the update of Setting up Python dependencies and installing MQTT Python Libraries  

NOW! I remember, On boot I have to start the subscriber program.  I'll look in a previous writeup and see if I described the process. 


This goes quickly but gives instructions on how to enable the subscriber. and set the broker to run in the background. 

https://www.youtube.com/watch?v=za-IIZ1xVbA



22/10/24  https://forums.raspberrypi.com/viewtopic.php?t=318784  this gives some good advice for simplifying subscriber.

23/11/24 Useful commands  https://linuxhandbook.com/systemctl-commands/

https://randomnerdtutorials.com/how-to-install-mosquitto-broker-on-raspberry-pi/

https://randomnerdtutorials.com/testing-mosquitto-broker-and-client-on-raspbbery-pi/

https://pimylifeup.com/raspberry-pi-mosquitto-mqtt-server/

https://tutorials-raspberrypi.com/raspberry-pi-mqtt-broker-client-wireless-communication/?utm_content=cmp-true            [ this one needs some editing and explanations.]

 What I am missing is "sudo python mqtt_subscriber.py"  and what I need is to know how to enable this in startup. 

Useful from Pimylifeup:  sudo systemctl status mosquitto

Starting subscriber at login:

https://linustechtips.com/topic/1465144-run-python-scripts-on-startup/

Few ways,

 

Create a bat file and put it in the startup folder.  The bat file would look something similar to this

python3 [path to run]

Or however you run a python script on your computer in command prompt.  Confirm that it runs your python script and then put in your startup folder and it will run at login.

 

Other options, go to task scheduler.

Create a new task

Add a new trigger; selecting on startup (I can't remember you might need to click the run even if user isn't logged in...can't remember exactly when that triggers).  You could also do on login


EVEN Better:

https://www.howtogeek.com/687970/how-to-run-a-linux-program-at-startup-with-systemd/


=======================================================================

starting from scratch.


2025-1-4 image imaged onto 16Gb card. Set the userID and wifi parameters.

Fing shows RPi at 192.168.1.26

Had to change keygen, but then able to login via ssh.

sudo raspi-config to expand filessystem, and reboot.


sudo apt update, 

sudo apt-get install firmware-zd1211.

and nmtui to configure Ethernet IP and Wifi 

Ethernet   192.168.1.9/ 24    GW=192.168.1.31

Wifi  rc-car Ashmeads  Access Point 192.168.4.1/32  GW 192.168.4.255


 sudo reboot  

on ip .9 - good

check ifconfig

OK. 


Now see above to set up MQTT


https://diyi0t.com/microcontroller-to-raspberry-pi-wifi-mqtt-communication/ 

See Broker setup

Installation doesn't like reference to Raspian. 

Looks like it needs a DNA specified in IP config.   Back to nmtui.  No effect.

Found 

https://stevessmarthomeguide.com/install-mosquitto-raspberry-pi/


Which includes some setup that the others haven't even if it has not been updated for Raspbios 'Bookworm'.


But problem here too:

Resolving repo.mosquitto.org (repo.mosquitto.org)... failed: Temporary failure in name resolution.
wget: unable to resolve host address ‘repo.mosquitto.org’

None of the solutions seem to work because 

sudo systemctl status systemd-resolved.service  could not be found. 


More work needed here: Tomorrow. 
























Friday, 19 April 2024

chicken feeder using stepper motor

 Evaluate these programs   19/4/2024


https://www.instructables.com/Automatic-Chicken-Feeder-3/

needs T-cobbler, the DRV8825 and the HX711 

Software needs MySQL

On R-Pi it uses one pin for the steps and one for the direction. I don't understand that because it uses an Archimedes screw to feed the food. 


https://www.backyardchickens.com/articles/a-raspberry-pi-controlled-diy-coop-door-with-python-code.74113/

Simple DC motor with pulley to raise/close heavy plywood door. 


https://www.instructables.com/Automated-Chicken-Coop/

Uses R-Pi B+  MySQL, Ordinary brushed motor. 

https://www.theneverendingprojectslist.com/raspberrypiprojects/automaticpetfeeder/

rotating 6 blade paddle for supplying food. 


https://www.instructables.com/Automaticcoop/

RFID tag to detect chickens, also ultrasonic sensor 

School project.

uln2003 for driving stepper motor

Stepper motor has a pulley for lifting door. 


This one gives good simple explanation of connections that I can use and basic Python program for R-Pi

https://www.electronicwings.com/raspberry-pi/stepper-motor-interfacing-with-raspberry-pi

Getting HW-95 motor driver wired up:

https://popularelectronic.com/Details/HW-95--L298N-STEPPER-MOTOR-DRIVER-MODULE


2 May 2024 It has taken me a while to get the Raspberry Pi set up, because you can't configure the Networking before you put the card into the R-pi.  It was necessary to attach a keyboard and screen and use nmtui to configure the Ethernet and wireless. 

It works and I was able to ssh into it and load the program from Electronicwings above, which caused the motor to vibrate, even if not turn. 

M8 threaded rod = 20 threads/inch, Stepper motor does 8 moves/revolution, Needs to move box 2 inches.   20 x 2 x 8 pulses = 320 pulses. 






Wednesday, 27 March 2024

Testing 3D cad programs -

 There are a number of 3D design programs available, but which is the best for me? 


I have been using TinkerCad, partly because this is the one suggested by Robert Murray-Smith in his interesting YouTube videos, but my son suggested FreeCad, and Tom Stanton suggests Fusion360 and Onshape.


To evaluate these programs I will attempt to create a chicken feeder consisting of a rectangular tube with a sliding rectangular tube inside it. Both tubes have holes in them to let food into the inner tube and dump it out when the tube has moved. 


For testing I will start with a new install of Kubuntu 22.04 on my quite old computer, and where a browser is required use Firefox. 


Evaluation criteria will be along the lines of: Ease of installation; how to get started; Ease of visualisation and adding/subtracting parts from the design, and exporting the design to a 3D printer. 


TinkerCad:  This is a browser based program, with all the elements on-line. https://www.tinkercad.com/dashboard  No storage is required on the computer.  It is necessary to create a logon, which is simple. To get started on the initial screen there is a ‘+ Create’ button that brings up a clean homeplate with a title label at the top that is a random name that is easily changed. 


To start, drag a block from the side panel of shapes on to the homeplate. There is a panel of basic shapes shown and you can select others from the shapes library. At this point I am inclined to select a shaded out shape that is the remove material shape, make it slightly smaller and put it inside the box to create a tube. Then I can group these two shapes and elongate the box to create a tube. It sounds simple but takes some practice to get positioning of components right. 


Once the shape is complete and all grouped together via the ‘group’ icon, I can export/download it as an .stl, .obj  or .gbl file for preparing for the printer.   Cura then gives me a slightly more realistic view of the object to be printed.


FreeCAD:  Version 0.21.2 downloads as an appimage. This means that it can be run directly once the properties of the appimage have been changed to specify ‘executable’.  It starts up without any need to login again, as you might expect. Despite the fact that there is a cube in the top right to specify the view of your object, it is necessary to Hit the ‘+’ to start a new design, then to change the name in the properties box in the bottom left. Then I have a blank build area.  In the top  selection box there is a label ‘Start’ and this gives you a selection of shapes to start with. I selected ‘part’ and then chose box. On the options bar this then shows a variety of shapes. Some of the technical terms in this program are beyond the simple modeller. I don’t know how I am going to change this box to an empty shell. It is not obvious how to do dimensioning and the help is no help. Users Documentation from the Help menu suggests adding add-ons for dimensioning. It goes to external 3rd party add-ons. 


The design is saved with a .FCStd extension, but can be exported in about 40 formats. 




Fusion 360:   This is a downloaded program for personal use. It seems to want my details more than once. I had to re-enter them to activate the download. [ Spelling mistake on web-page - my bugbear] Then it seemed to have a run-around before I discovered that there is not a linux version.   


Evaluation stops here. 


Onshape:   This is available as a free to non-commercial single user (Me!) and pay for more  features. There are quite a few questions in setting it up, but an important one is setting the dimensions from the default imperial to metric if you need that. 

It is an online tool accessed via the browser. I like that it has a Quickstart Introduction link on the front page. However, I found a youtube video on getting started that was better to get started with my simple design.  https://www.youtube.com/watch?v=pMWnsHpDlQE&list=PLxmrkna-ixrIQmsPR3MITi4Ru1bnMH4-l




Now that I have my creation, I need to find out how to export it for my 3D printer.





Summary   


And then I found:

https://www.youtube.com/watch?v=J--QVhGheP4


So I gave up.


The Author:  Peter Merchant is a retired Electronics Engineer and University Lecturer. My engineering career has always been involved with Data Communications. I have programmed in a number of languages in the course of my work, and since retirement. Nowadays I guess I would call myself an Inventor/maker/fixer. I learnt Mechanical Drawing/Draughting in 1972 as part of my Engineering degree. 


—----------------------------------------------------------------------------------------------------

4 April 2024

I have just seen a video  about a new product called Plasticity.  https://www.youtube.com/watch?v=Lt29GkADMZ8&t=318s    It seems to have been created by a single guy, and from reading about it he is behind the iron curtain and can't get upgrades on some stuff to improve it. 







Wednesday, 28 February 2024

Feb 2024- Solar panels have paid for themselves - sort of.

 I have just done my reckoning for the year and  the solar panels after 9 years have paid back the cost  of purchase.  They cost £6000 and at the end of this year have paid back £6150.


Lots of caveats in here though. I figure that if the £6000 had earned 2% it would now be worth over £7000 but of course interest rates have been down and are now up again. I have not adjusted it annually.

I costed in the benefit due to reduced electricity/gas bills compared to the cost of these in 2014. Except for the last two years my bills have been £2-300 lower than 2014. Caveat: consumption may be different. 

Caveat: the last two years the cost of electricity and gas has been much higher and therefore my costs have been greater than 2014, so I have not offset them in my calculations.  It wouldn't have been easy as the rates have fluctuated in the last couple of years.

RECALCULATIONS December 2024:

Putting together the results of emails with a friend with solar panels. 

When I got my solar panels fitted in December 2014, in order to calculate the breakeven point, I took the cost of elec/gas for the previous year [2013] and used that as a base point to calculate the savings. Of course this didn't include in the calculations the varying price/unit of these. What has happened over the last couple of years is that the cost of gas/elec over the year has been higher than the 2014  value so my calculations of savings are negative.

I have most of the bills over these years so I could recalculate everything if I had to. It's difficult I know because my consumption has varied over the years, and now that I have all new appliances in my kitchen and no more gas oven/hob, the usage is going to change.

At the moment  my calculations for this year only include the FIT payments because a negative figure isn't relevant any more. 

—-

Some parts of mine are more complicated as I did an annual calculation on the reduction in the bills, based on annual usage taken from bills, and also had an increment on the initial cost of 2% which would be the interest the money would have earned in the bank.  In many cases the annual interest on the capital would have varied, but I didn't worry about that, and also the annual cost calculation is only an approximation as the rates would have changed mid-year.   It could have become very complicated to try and get it totally accurate.

Good Energy handle my FIT payments, and I did query the fact that my calculation of FIT payment was different from what they gave me, but didn't get anywhere.   I am still about a year from breakeven I think [Dec 2024].

see sheet 'totals' on attached link

https://docs.google.com/spreadsheets/d/1_KJGPu5fO4yIRw5Hr7BDt3Ia9UJRNkx0twsA16mEl_Q/edit?usp=sharing


—-

I have reworked it all using a different calculation, not based upon cost differences, but on usage.

Every year I compared the usage to the reference usage in 2013, before panels, and using the rate for a year, calculated the savings due to using less electricity. I created a new sheet[NEWTOTALS], and in column I for each year is the rate and then the calculation for that year. It's not entirely correct because for a couple of early years  I couldn't find bill copies to get the rate, and also in each year the rate was usually renegotiated about June/July. I used the rate in September for the calculations. Interestingly the saving in the early years was less than with the previous method, and in later years was greater (esp. when values went negative!).

An added factor from 2020 on was that the rate did not include VAT and this was added later to the bill, so a multiplication factor of 1.05 is added.

This gives me a much closer to breakeven than the previous method of calculation.

Breakeven = 7314 (Interest on Purchase price)   By the previous method of calculation= 6482,

The new Calculation has a saving so far of = £7174 to  November 28 2024. This assuming a FIT payment the same as last year for the last quarter.

So it all depends on how you do it! And there is margin for error.






Thursday, 21 December 2023

E-Bike electric systems - my investigation

 So far in looking at ebikes I have come across four types of electric motor systems. I want to know the difference. 

The guy at Pedals cycle shop said that in-frame motors respond to pressure on the pedals to supply power, where as rear-hub systems  go on speed. Is this true?

I am not considering front hub systems like Swytch. I am not interested in them.

I like the concept of the Quella bikes where there is no electrical connection between the wheel and the battery. https://www.quellabicycle.com But they are all single speed bikes. 

Halfords Boardman bikes use the Fazua Evation system. 

--

What is Fazua Evation?

The Fazua Evation e-bike drive system features a hidden, integrated motor capable of producing250W of power assistance and 60Nm of torque. This is combined with a removable 250Wh battery, which makes for easy charging without needing a plug where you store your bike. With a range of up to 56 miles* on the “Breeze Mode” setting, long rides are efficiently dealt with.

Using a sophisticated combination of Torque, Speed and Cadence sensors, the Fazua system closely monitors your pedalling and feeds in power smoothly when you need it, stopping instantly when you stop pedalling[1]. You’re always in complete control. There are 3 levels of assistance to choose from using the intuitive handlebar remote control, which also shows battery charge levels.

Weighing in at just 4.6Kg for the whole system, the Fazua Evation system keeps the Boardman HYB-E and ADV-E e-bikes lightweight and practical to live with. The battery and motor can also be removed [2] and replaced with a lightweight cover (sold separately), meaning you can ride your e-bike just like a normal bike with barely any weight penalty and no extra drivetrain resistance if you decide you don’t need any assistance.

Fazua App

By using the FAZUA app which is compatible with all Boardman eBikes, you can get access to all of the below that will assist your journey and will help you learn more about your training and your bike.

--
Questions on that. [1]Motor stops when you stop pedalling?
[2] Battery and motor can be removed easily?
--

Here is a report that describes the types of motors, but doesn't answer all of my questions and indeed, raises some more:
https://bicycleuniverse.com/best-electric-bike-motors/

So two types of hub motors and no suggestion as to how the use of the motor is controlled. It also suggests that 28mph is the maximum where in the UK ebikes are limited to 15mph.  No date on the article so we don't know how old or relevant it is.   None of the articles mention that hub motors need a means of getting the electricity to the motor from the frame and how susceptible to problems this is. 

One article suggests that hub motors are usually heavier than mid-drives, but I ask if the frame is heavier for a mid-drive.

Lets have a look at a couple of hub motor bikes and see if they tell what sort of motor it is:
GT eGrade Bolt:  MAHLE ebikemotion X35 250W   
https://www.mahle.com/weshapefuturemobility/en/
This motor doesn't use rare earth magnets, but electromagnets. 






Monday, 18 December 2023

Thoughts on Leaves, and God

 It seems that any time I hear of any conflict in the world, it is due to quarrels between different religions. I remember  some lectures that we went to by the Christadelphians, where it was pointed out that in the far distant past in the middle east, two brothers went their separate ways, and one became the Jewish group, and the other became the Muslim group.  There were lots of other tribes in that area too over the centuries, so I don't know how that fits in. 

But each of these religions is man-made, in somebody's idea of how god should be worshipped. God hasn't had any say in this. That's why I can't support any church, because it is just somebody's idea of how things are. 


I look at the leaves on the trees, and think that these are the foundations of life. They generate the Oxygen that we humans require to live, so they give us life. They fall off periodically and are regenerated  the next year, meanwhile providing the life around them with fertilizer to grow.   

I had a lot mor thoughts about this, but it has gone now.