CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Stuck in Programming, need a little help

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
daalex



Joined: 10 Jan 2014
Posts: 10

View user's profile Send private message

Stuck in Programming, need a little help
PostPosted: Sat Jan 18, 2014 6:46 pm     Reply with quote

Hello to all,
First of all, I want to apologize for my bad english ...
I'm new here in this forum and have a small question to the professionals...

At the moment I'm working on a small program to control a R/C Car via wifi and my Smartphone.

My problem is that I want to implement a PWM and my idea is to put the PWM values directly from my Smartphone to the microcontroller.

Just for example: FL 255 255 -> Means forward left with full speed
(the values are between 0 and 255).

Now the question: is this a good way to handle that or should I choose another (maybe easier) solution?

How would you solve that?

Nice greetings from Austria :-)
temtronic



Joined: 01 Jul 2010
Posts: 9246
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sat Jan 18, 2014 7:16 pm     Reply with quote

It's easy enough to do, provided you breakdown the project into smaller units.
Virtually any PIC will work as the 'interface' between the wifi and R/C car.
Step one would be to get the PIC to control the R/C car,you probably need 2 rc servo outputs( speed, direction).Once that is operational, then add the wifi->PIC interface module. As 'wifi' has several 'meanings' just be sure to use one that easily interfaces to your 'smartphone'.
Obviously ,you'll have to create an 'ap' for your smartphone which obviously has nothing to do with PICs.
Depending on your level of expertise it could take you a few hours or several dayze. As I first sad , the key is to break it down into smaller,managable units.

hth
jay
daalex



Joined: 10 Jan 2014
Posts: 10

View user's profile Send private message

PostPosted: Sat Jan 18, 2014 9:57 pm     Reply with quote

Hi and thanks for answering.


well, the app and the wifi Connection is already working and the car is driving in all directions...

the Problem is only the pwm parameter, I dont know what the "best" solution would be to send de driving variables.

working with strings or is it better to use other Solutions?
gpsmikey



Joined: 16 Nov 2010
Posts: 588
Location: Kirkland, WA

View user's profile Send private message

PostPosted: Sat Jan 18, 2014 10:25 pm     Reply with quote

Depending on exactly how you are doing this, one idea to consider is to send the PWM value with an identifier on it - the first character could be a letter to indicate Forward, Backward, Right or Left for example (FBRL) that way it is easy on the other end to know which command it is receiving (and you are less likely to get out of sync). I think I would stick with the numeric value as a string rather than trying to send binary - strange things happen sometimes with various utilities when they see what they perceive as control characters. It isn't that hard to convert the string "F253" back to Forward with a value of 253.

mikey
_________________
mikey
-- you can't have too many gadgets or too much disk space !
old engineering saying: 1+1 = 3 for sufficiently large values of 1 or small values of 3
temtronic



Joined: 01 Jul 2010
Posts: 9246
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sun Jan 19, 2014 6:44 am     Reply with quote

You can actually send command and data in one byte if you can sacrifice a bit of RC servo resolution.
Have your 'ap' set/reset bit 7 based on direction or speed 'command'(0=direction, 1=speed). The other 7 bits become the 'range'. About 1 bit per servo rotation degree(128 bits gives 180*).
The PIC receives 1 byte,then parses it.A simple bit test for bit 7 decides if direction or speed servo is to be updated, the remaining bits are used to caluculate the PWM to that servo(1-2ms).
What you get is super fast,efficient code.I did this using a PIC16C84 and PCMV2.5xx to control 4 servos.Though it gave me 64 bits per 180* it was more than enough for the project.

hth
jay
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group