4 Replies Latest reply on Apr 25, 2017 3:19 AM by mohamedmongihajjej_2408286

    5 servo and  5 Potentiometre by Two Psoc 5lp

    mohamedmongihajjej_2408286

      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 

        • 1. Re: 5 servo and  5 Potentiometre by Two Psoc 5lp
          bob.marlowe

          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

          • 2. Re: 5 servo and  5 Potentiometre by Two Psoc 5lp
            mohamedmongihajjej_2408286

            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

            • 3. Re: 5 servo and  5 Potentiometre by Two Psoc 5lp
              bob.marlowe

              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

              1 of 1 people found this helpful
              • 4. Re: 5 servo and  5 Potentiometre by Two Psoc 5lp
                mohamedmongihajjej_2408286
                        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