5 servo and 5 Potentiometre by Two Psoc 5lp

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

How to controle 5 servo (9g) by ADC (input from potentiometre)  from 0 To180°

   

thank you 

   

secound step ; how to use uart to sent 'analog input' to an other  Psoc to controle the same 5 servo 

0 Likes
1 Solution
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

The specs for your servo are:

   

Pulsewidth = 1ms -> Leftmost position

   

Pulse width = 2 ms -> Rightmost position

   

Repitition rate 20ms / 50 Hz

   

So what you need is a PWM component configured to a period of 20ms. By setting the compare value accordingly you will be able to control the servo position at your need.

   

Example:

   

Input clock 1MHz

   

16 bit wide PWM USB type. One output

   

Period value 19999

   

Compare value 999 to 1999

   

You will need a function that converts your ADC result to the required compare - value (ADC * Gain + 999)

   

"secound step ; how to use uart to sent 'analog input' to an other  Psoc to controle the same 5 servo "

   

You will have to design a communication protocol. This fixes

   

What is sent

   

Who may send

   

What is the response (good / bad)

   

best could be to define a structure of the data to be send which contaoins a lead-in (starter byte) and a lead-out (end byte) which allows for synchronization of the input stream. Both of your PSoCs may not be switched on at the same time or when a byte was lost this feature will be very helpful.

   

 

   

Bob

View solution in original post

0 Likes
4 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

The specs for your servo are:

   

Pulsewidth = 1ms -> Leftmost position

   

Pulse width = 2 ms -> Rightmost position

   

Repitition rate 20ms / 50 Hz

   

So what you need is a PWM component configured to a period of 20ms. By setting the compare value accordingly you will be able to control the servo position at your need.

   

Example:

   

Input clock 1MHz

   

16 bit wide PWM USB type. One output

   

Period value 19999

   

Compare value 999 to 1999

   

You will need a function that converts your ADC result to the required compare - value (ADC * Gain + 999)

   

"secound step ; how to use uart to sent 'analog input' to an other  Psoc to controle the same 5 servo "

   

You will have to design a communication protocol. This fixes

   

What is sent

   

Who may send

   

What is the response (good / bad)

   

best could be to define a structure of the data to be send which contaoins a lead-in (starter byte) and a lead-out (end byte) which allows for synchronization of the input stream. Both of your PSoCs may not be switched on at the same time or when a byte was lost this feature will be very helpful.

   

 

   

Bob

0 Likes
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

fist step working  now sir

   

but from 0 to 90° LOL crazy time i think for me

   

thank you so much for ur help

   

can u help me how to creat a protocol uart? about what i  say befor....

   

look to my first progrme sir using one servo and one potentiometre

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

When you want to use sprintf() you need to

   

set the heap size to 0x0200 (in System view)

   

enable newlib nano float formatting (in Project-> Build settings->Linker)

   

 

   

Bob

Anonymous
Not applicable
        Im not sure if i want to use sprintf() Coz really i dont know the good way to do that.. exactly to sent data "angle of evry servo"...by uart.... Just all i want is how to creat a protocol.. how to sent data... In psoc ... coz with "arduino i creat a protocol for the dsame project.. with two arduino uno card and it working... Thnks again Ms Bob   
0 Likes