Saturday 2 April 2016

RC-Car-1 RAspberry Pi to drive ex-RC car

27-10-17 New comments at end.
------------------------------------------

22-2-16, Finally got Raspbian Jessie wirelessly connected to network on IP 192.168.1.8.  errors and struggle was due to wrong ESSID. [note _ instead of - ]

 I have installed Apache as per the instructions I am currently following. and have connected to apache base page.


see:


27-2-16 Testing basic html on R-Pi.    Have nicked  buttons from here as the ones that I found didn’t format nicely.  These do OK.


Now I have taken my LED blink program that tested three GPIO ports and edited it so that different buttons  with different GPIOs. On each prog I have cut out two ports. I have  read up how to call Python direct from HTML, which seems to use CGI anyway.   This needs testing.


I have discovered that the connections on my GPIO breakout box are correctly labelled. the labels P17 stand for GPIO17 which is actually pin 11 on the GPIO pins.


The programs now refer to that in the naming as blink17/22/23.


Then things like how to terminate the python program when you leave the button for left/right, and how the stop will stop the forward action.


I have just discovered that I have a permissions problem with the blink programs.  ssh into it and change permissions of the blinkxx.py files to 777. It still just lists the files.


1/3/16 Have asked question of the web site above, but no response yet. Am looking at




but he uses a feature called fastcgi. that is more complex.


and:
https://www.raspberrypi.org/forums/viewtopic.php?f=31&t=96200 has some comments. I haven’t tried it yet.

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

3/4/16 I have made two attempts using samples that I found on the Internet.

This attempt number three

26/3/16 This one is going to be developed using the notes from


and mostly from


27/3/16 New card; Raspbian Jessie 18/3/16, wired into router, IP=192.168.1.19 (found with fing from tablet)
ssh into it,
Ssh -l pi 192.168.1.19 from Drive/R-Pi-initial setup
then expand filesystem using sudo raspi-config, and reboot
Sudo apt-get update
Sudo apt-get upgrade
sudo apt-get install zd1211-firmware
sudo apt-get wpasupplicant  [ though it may already have the latest]
sudo apt-get install lighttpd


configure network from Drive/wireless Configuration
configure wpa-supplicant using nano on the unit.
reboot wireless
For once it worked first time

how do I get WebIoPi tar file on to the R-Pi? Download it to kubuntu, copy it on to the SD card, and:
It is very easy to install WebIOPi on the Raspberry Pi. You have to download the WebIOPi file from the WebIOPi homepage and extract the file. After this you have to install WebIOPi and that is it. To do so you need a few commands I listed here:
The command to extract the WebIOPi tar file: tar zxvf WebIOPi-0.7.0.tar.gz
Now you have to change the directory to the folder where the WebIOPi files are extracted to.
With the next command you will install WebIOPi on your Raspberry Pi:
[sudo python setup.py install]    Invalid 
sudo ./setup.sh    works     [13/11/2017]
Now WebIOPi is available and can be used.
------------ ------------ ------------
WebIOPi successfully installed
* To start WebIOPi foreground : sudo webiopi [-h] [-c config] [-l log] [-s script] [-d] [port]
* To start WebIOPi background : sudo /etc/init.d/webiopi start
* To start WebIOPi at boot : sudo update-rc.d webiopi defaults      - must do this next time I connect to th R-Pi
----------- ----------- -------------
Put rapi_car_webio.html in www/html directory and it was picked up by browser.
So far so good. 
Hardware:
Had a look at the car. The rear wheels are driven via relays, and it looks like one of the inputs to the circuit is via a capacitor, even though they are DC motors. There is a chip that does all the intelligent stuff from receiving the RF signal to driving outputs. [SCRX2FS] Unfortunately, the spec sheet for this chip is in Chinese, but the pinouts are in English, so perhaps I can sort that out.



Here is a picture of both sides of the PC board in these cars. In the two relays the lines to the rear wheels are held at ground unless a relay is energised, then the motor drives. I have noticed that the line to the motor from one relay goes through a capacitor, so I wonder if they are driven by PWM as many seem to be.


Just southwest of the IC are two surface mount transistors that switch the relays (Q2, Q3). The multiple wires (blue,green,orange,yellow,red) run to the front wheel steering module. I don't know how they work. 

[6 April 16] From the spec sheet I found at the bottom a circuit diagram.

This shows which pinouts of the chip drive what.  [I am not sure how to make this image darker].

It does show me how For [11] and Back[10] drive the rear wheels, and Left [7] and Right [6] steer. 

I just need to know what all these other lines running to the steering box do. Guess it's time to open it up.   Blue and Green drive the motor. Brown, orange, yellow, and red are a Gray code wheel with brown as the common, for feedback.  That's not in this circuit diagram! 


My current thoughts are that If I remove the chip, I can use those pinouts to drive the motors directly from the Raspberry Pi. 

[10 April 16] Current problems are working out how this gray code thing on the steering works as feedback  for the control. As I have no circuit diagram it is difficult.
Secondly, looking at the python code for driving the car, it has two drive motors, one for each side and steers by adjusting the PWM for these motors. I'll try it just to see if it works before modifying it. 

[12 April 16] No, I need to modify the code, or else if I try it it will turn as well as go. I need to separate the two functions. Motor 1 is driven by pins 22 and 27, Motor 2 by 24 & 25.  What I propose is to change the code in the sections for Forward/Back Left and Right to Motor 1 being forward and back, motor 2 being Left/Right. 

[15 April 16] edited rapi_car_webio.py file to comment out the motors that I did not want to drive for forward/reverse/left and right. 

now need to test with LEDs

[19 April 16] connected LEDs to pins 24 & 25, set webipoi to run at startup, and also started it, but couldn't get LEDs to light. Must put in modified Python Program to test.

[20 April 16] Noticed that the HTML program does not call the Python Program. Funny. Look again and look at the webIOPi site and see how it should work, otherwise ask author of cardboard car.
The Python Program should be called script.py  and edit /etc/webiopi/config  to specify locations. 

[24 April 16] searched for webiopi debugging on internet and found
 https://www.raspberrypi.org/forums/viewtopic.php?f=37t=78471  This indicates that I also need to edit  /etc/init.d/webiopi  to specify file names and restart service. Didn't find this in webiopi instructions. 
Debugging output commands suggested after doing this are 'systemctl status webiopi.service' and 'journalctl -xn'.


[13 June 16]  On one of the PCB's I ripped out the chip and connected a USB connector to the 5v and Ground contacts. On the two tabs out of the chip to the Transistors for the rear motor I connected wires. I touched these to the +,gnd and the motors jumped - well and good. 

On another set of back wheels without the PCB, I touched +3 volts to it and the wheels spun- Therefore it is a direct drive motor and not a PCM driven one. 


[Oct 27 2017]  Have been struggling to find a battery to drive the motors, but I picked up another RC car at the tip and it contained a Li-Ion battery. A real treasure of a find. I have  charged it up using a 9 Volt/ 0.8 Amp power supply and a 100 ohm resistor, and soldered the leads out of my new find onto the board of my RC car. It all works a treat. It goes very fast, so I think I'll have to look into some sort of PCM speed control. This is available in webIOPI.  

Comments on charging: I found a 4 pin square connector from an old PC PSU, and two of the pins were in the correct orientation for the plug on the battery so it was cut down to provide the charger connector.   I monitored both the current and the voltage on a couple of power supply units before using this one. 

[Nov 9, 2017] Observations. 
It works, But has no speed control. Forward is forward at full speed, as is reverse, and Left and right immediately crank the wheels over hard until I stop them, which usually means it has done at least one complete circle. In  script.py There is  no code about them, so I have added lines to control the turning and switch it off after 300msec. 

But so far I am pleased.

[10/11/17]  I can't stop. I now have put in Left/right turn controls with 300msec  bursts of turn into the python script, and it works on the LED test rig. Must try it in the car now. For the record, this is SD card #4.













No comments: