Remote control from smartphone

 
3r3-31. In two previous articles, I talked about using a smartphone to control a toy car, either directly with the voice or using another smartphone via Bluetooth. But management was primitive - the team was given, the car carried out the command, stopped and waited for the next command. This was due to the high speed of the car for room conditions (approximately 1.2 m /s), as well as the long time the command was given and the inability to quickly intervene in the movement using the menu. Even the regular remote control did not give control. In the new version of the remote control with a graphical interface, I decided to use PWM to adjust the speed and simulate steering.
 
 
Remote control from smartphone  
 
The picture shows the machine, which controls the smartphone, and below the smartphone with a running remote control program for bluetooth.
 
3r314.
 
At the top of the screen is a slider (green circle) moved by a finger.
 
 

 
 
When you remove your finger from the screen, the relative distance from the slider to the left edge of the screen is transferred to the control smartphone, where the latitudinal modulation of the pulse signal is formed.
 
 
GR.GET.POSITION c? xx, yy
r6 = (xx-xc) * (xx-xc) + (yy-yc) * (yy-yc)
IF r6
 
The smallest signal ratio of 20%, the largest 80%. The theoretical possible frequency is 10 Hz. In fact, probably around 4 - 5 Hz, since the signals for modulation go in the general flow of commands, and some of them also have a time delay. Therefore, at a low duty cycle, vibration is clearly visible.
 
 
Two green buttons - upper forward movement, lower back. On the right red button - to stand still. Two white buttons - stop programs on the remote control and on a typewriter. At the bottom of the screen are three purple buttons to choose the direction of movement to the left, right and right. With 3r3121.  
on, the corresponding mode, in the center of the button appears a circle of smaller diameter and the same, but darker color. To control the direction of motion in addition to the buttons, I also used the accelerometer. In the horizontal position of the smartphone, the projection of the gravitational acceleration vector on the axis 0Y equals ? which corresponds to the movement straight (see figure above).
 
 
3r361.
 
 
If you lift the left side of the smartphone, the projection will be with a + sign, which will correspond to the movement to the right.
 
 
 
 
If you raise the right side with the sign - that will correspond to the movement to the left.
 
The program reads the accelerometer and sends the corresponding commands to the smartphone driving the car, displaying the mode on the buttons.
 
 
    SENSORS.READ ? sx, sy, sz
IF (sy <=1)&(sy> -1) & (lrsh) THEN
rsh = 1
lsh = 1
lrsh = 0
GR.HIDE cc13
GR.HIDE cc15
GR.SHOW cc17
GR.RENDER
BT.write "f"
pause 100
ENDIF
IF (sy> 2) & (rsh) THEN
rsh = 0
lsh = 1
lrsh = 1
GR.HIDE cc13
GR.HIDE cc17
GR.SHOW cc15
GR.RENDER
BT.write "r"
pause 100
ENDIF
IF (sy <-2)&(lsh) THEN
Lsh = 0
Rsh = 1
pause 100
ENDIF
3r3-3202  
This is how the remote control works. The work of the car control program has also changed, but not very significant. In the future, I want to supplement the program with the functions of memorizing commands and executing them automatically.
+ 0 -

Comments 2

Offline
morning world
morning world 11 November 2018 09:35
Thanks for this great  post, i find it very interesting and very well thought out and put together.  I look forward to reading your work in the future.  Salem  OR
Offline
morning world
morning world 12 November 2018 09:47
I was  surfing the Internet for information and came across your blog. I am  impressed by the information you have on this blog. It shows how well you  understand this subject. טיול  מאורגן

Add comment