Mintoris Forum

Author Topic: Hobbyking Wifi Remote  (Read 2894 times)

jeromebg

  • Jr. Member
  • **
  • Posts: 2
Hobbyking Wifi Remote
« on: May 08, 2015, 04:49 PM »
Hi, just bought your app but I'm a totall newbee with basic…
I would like to build a very simple app to control the hobbyking wifi rc, saw you already done this in the forum.
Basicly I would need a button, and onclick execute a sequence and stop (it's to build a panoramic head)
Only two of the four channels are needed, one for a continuous servo and the second one for the shutter release.
The sequence should do something like this :
channel 1 :go from 50 to 100 during x time and go back to 50
channel 2 :go from 50 to 100 during x time and go back to 50

4 times and stop until the next time button is pressed.

Could anyone give me a clue on how to program this ?

Thanx a lot for your help ‼

Chuck

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1899
Re: Hobbyking Wifi Remote
« Reply #1 on: May 11, 2015, 01:44 AM »
The demo post has a simple demo program that you can use to get started. See if you can get the servos to move and then work on the interface.

Hobbyking WiFi Receiver Control Demo

jeromebg

  • Jr. Member
  • **
  • Posts: 2
Re: Hobbyking Wifi Remote
« Reply #2 on: May 11, 2015, 06:33 PM »
Thanx  Chuck ‼
I tried this but the servo rotation is very eratic ans doesn't seems to stop :
Code: [Select]
sendRawChannels(100, 0, 0, 0)
wait 1
sendRawChannels(50, 100, 0, 0)
wait 1
    loop
 

first line is to rotate the servo 90°
second one is to release the shutter

maybe wait isn't the good way to go ?
How to tell the servo to rotate during x time and to stop ?

Thanx for your help ‼

Chuck

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1899
Re: Hobbyking Wifi Remote
« Reply #3 on: May 12, 2015, 01:18 AM »
You must continually call the sendRawChannels(100, 0, 0, 0) every 50ms or so to hold the servo position. This mimics the way an RC controller sends out a servo position pulse every 50ms.

Try something like this.

Code: [Select]

    pos1 = 0
    pos2 = 0

    do while TcpGetState(1) = 1

      ' set your channel values here.
      sendRawChannels(pos1, pos2, 0, 0)

      touch x,y, 50 ' Here is your 50ms delay

      if x >= 0 then
        print x,y
        ' change pos1 and pos2 based on x,y (touch pos)
      endif

    loop

In order to move the servos smoothly you need to change pos1 and pos2 slowly over time. You can use the time() function to get the current time (in milliseconds) and use it to increment pos1 a little bit each loop.

Once you get your servos under control and you really understand how the main loop of your program works, I'll help you out with the movement over time calculations. At some point you'll want to turn on the graphics mode and draw a few buttons.

-Chuck
« Last Edit: May 12, 2015, 02:15 AM by Chuck »