programme problem

well I have built my robot successfully yesterday, but my programme had some problem (again).

So here the problem is:

If I download this code completely, only signal from channel 2 would work.
If I cut those parts about spinning, it worked correctly.
If I cut all parts expect that, it worked correctly as well.
if I set ch3 & ch4 for normal movement, ch5 for spinning, ch6 for flipper, ch2 for dumper, it worked correctly as well.

So it seemed to be such a strange problem to me and It successfully got me into a mess.

Looking for your help and great appreciate.

Here the code is.
Anarkia_dual_v1.0 beta 1127.zip (21.9 KB)

This is very interesting… You are using EasyC v.2??

#include "Main.h"

void main ( void )
{
      unsigned char a; 

      while ( 1 )
      {
            OIToPWM ( 1 , 3 , 1 , 0 ) ;
            OIToPWM ( 1 , 3 , 2 , 1 ) ;
            OIToPWM ( 1 , 4 , 3 , 1 ) ;
            OIToPWM ( 1 , 4 , 4 , 0 ) ;
            // a is used for spinning 
            a = GetRxInput ( 1 , 2 ) ;
            // motor 5&6 for flipper 
            Arcade2 ( 1 , 5 , 5 , 5 , 6 , 0 , 1 ) ;
            // motor 7&8 for dumperr (4 motor connected by Y-cable) 
            Arcade2 ( 1 , 6 , 6 , 7 , 8 , 0 , 1 ) ;
            while ( a > 127 )
            {
                  // clockwise 
                  SetPWM ( 1 , a ) ;
                  SetPWM ( 2 , a ) ;
                  SetPWM ( 3 , a ) ;
                  SetPWM ( 4 , a ) ;
                  a = GetRxInput ( 1 , 2 ) ;
            }
            while ( a < 127 )
            {
                  // anticlockwise 
                  SetPWM ( 1 , a ) ;
                  SetPWM ( 2 , a ) ;
                  SetPWM ( 3 , a ) ;
                  SetPWM ( 4 , a ) ;
                  a = GetRxInput ( 1 , 2 ) ;
            }
      }
}


What Happens if Channel #2 returns 128??? Maybe you should set a Deadband, basically set your While Tests to 127/128 +/- 12, like :


            while ( a > 139 )
            ....
            while ( a < 116 ) 

This will give you a larger middle area for your main code:


            OIToPWM ( 1 , 3 , 1 , 0 ) ;
            OIToPWM ( 1 , 3 , 2 , 1 ) ;
            OIToPWM ( 1 , 4 , 3 , 1 ) ;
            OIToPWM ( 1 , 4 , 4 , 0 ) ;

I don’t quite know what will happen with Channels 5 & 6 and using them with the Arcade Mode… The Arcade Mode should blend them like in the MPLAB Code, as described here in the Inventors Guide :

If all else fails try another controller you might have changed the settings on your controller and screwed up the channels. It’s easy to do and has happened to me on several occasions.