voorloopnul

About Me

My name is Ricardo Pascal, I'm a developer and sysadmin who lives in Florianopolis/Brazil. I enjoy work with projects related to Linux, Python, Science, Web, Django and Network.

g+ "I've seen countless science fiction movies and documentaries about the future of humanity. Nothing ... | it's a fun hobby | Matéria bacana que aponta floripa como a melhor capital para se empreender no brasil. | Axado está com vaga aberta para desenvolvedor Python & Django. | | A common use of web applications has been serving files, django is capable of that, but is usually not... | A common use of web applications has been serving files, django is capable of that, but is usually not... | For the first time since I became a Ubuntu user, I'm considering not update my system to a new release... | Now try arguing with these people.... #climatechange   #climatechangeisreal   #climatechangedenial ... | | VAGA PARA DESENVOLVEDOR BACK-END PYTHON Requisitos: • Mínimo de 1 ano de experiência profissional com... | A lot of great services free of charges if you are a student! | Oportunidade para programador python  na Gymglish de Florianopolis. "We document our code, unit test... | | https://micropython.org/store/ is open and accepting pre-orders!  | Venha trabalhar na Neoprospecta como pesquisador RHAE/CNPq. A Neoprospecta ainda possui uma vaga aberta... | Faking like a pro | "Since the virtual size of the cp process was now more than 17 GB and the server only had 10 GB of RAM... | now you can edit your requirements and remove south :)  | |

Controlling a motor using wifi connection and a gamepad

Hobbyking sells a neat wifi receiver to control planes and cars using android or IOS devices. So I bought one and used my computer and a gamepad to control a motor.

Protocol

A description of the receiver protocol can be found at rcgroups forum

"If someone is interested: The HK Wifi Unit can be used with any WIFI enabled device. Though I do not have a unit, I just checked out the code. The HK Wifi unit waits on IP 10.10.100.254 on port 8899. The socket timeout should be set to 1000ms. One message has a length of 11 bytes. The first 4 bytes are always 85-0-11-0. After that, the values of the 4 channels are transmitted in correct order (channels 1-4). The next 2 bytes (9,10) are not used at all (maybe space for another 2 channels in the future). The last byte is reserved as control byte. All 10 data-bytes are added and transmitted as last byte. I hope I could help you. I do not have the time to develope an android app at this very moment, but it should be really easy. Hope to see some in the near future."

Considerations

  • You can find some info about sockets in my previous post: how not to create a network game
  • If you buy the receiver from this link I will earn some cents to use on my next shop.
  • The Gamepad code requires the Pygame library

    sudo apt-get install python-pygame

Code explanation

  • It will run a loop and check for gamepad input. If you press the square buttom the connection to receiver will be stablished.
  • If you press the circle buttom, the power of all channels will down to 0, the connection will be closed and the loop will end.
  • If you move the left analogic stick in the up direction, the motor will gain a power increment.

The output from gamepad is a float between 0 and 1. I have defined the base power as 50, so for each .1 incremment in gamepad input, the motor increase it power in 5 units going to a maximum of 100.

The code


by Ricardo Pascal on Dec 16, 2012

comments powered by Disqus