Shop OBEX P1 Docs P2 Docs Learn Events
How many cogs am i using? — Parallax Forums

How many cogs am i using?

Hey everyone,

i have attached the beginning of my code. I believe i have 7 cogs running, i am wanting to add another ADC to measure the battery voltage and
display it on the screen.

question1: do i really only have 7 cogs running?
question2: would adding another MCP3208 ADC on the 8th cog cause any potential problems?
#include "simpletext.h"
#include "simpletools.h"                      // Include simple tools
#include "fdserial.h" 
//#include "servo.h"                            // Include servo header
//added "-std=c99 " in SimpleIDE's "Other Compiler Options" field.

fdserial *transceiver; //HS-LC12S transceiver
fdserial *lcd;  //nextion 4.3" screen
fdserial *JDY40; //JDY-40 chip


volatile int transmitterpause = 0;

volatile int chan1;
volatile int position1;
volatile int servo1;
volatile int d1;

volatile int chan2;
volatile int position2;
volatile int servo2;
volatile int d2;

volatile int chan3;
volatile int position3;
volatile int servo3;
volatile int d3;

volatile int chan4;
volatile int position4;
volatile int servo4;
volatile int d4;

volatile int chan5;
volatile int position5;
volatile int servo5;
volatile int d5;

volatile int chan6;
volatile int position6;
volatile int servo6;
volatile int d6;

volatile int chan7;
volatile int position7;
volatile int servo7;
volatile int d7;

volatile int chan8;
volatile int position8;
volatile int servo8;
volatile int d8;

volatile int offset1 = 385;
volatile int zero1 = 1500;
volatile int offset2 = 464;
volatile int zero2 = 1500;
volatile int offset3 = 400;
volatile int zero3 = 1500;
volatile int offset4 = 402;
volatile int zero4 = 1500;

volatile int offset5 = 695;
volatile int zero5 = 1500;
volatile int offset6 = 700;
volatile int zero6 = 1500;
volatile int offset7 = 700;
volatile int zero7 = 1500;
volatile int offset8 = 720;
volatile int zero8 = 1500;

// variables to store button names
 char button0[19];   //
 char button1[19];   //
 char button2[19];   //
 char button3[19];   //
 char button4[19];   //
 char button5[19];   //
 char button6[19];   //
 char button7[19];   //
 char button8[19];   //
 char button9[19];   //
 char button10[19];   //
 char button11[19];   //
 char button12[19];   //
 char button13[19];   //
 char button14[19];   //
 char button15[19];   //
 
//IO output values for JDY-40  
 int one = 0;
 int two = 0; 
 int three = 0; 
 int four = 0; 
 int five = 0;
 int six = 0; 
 int seven = 0; 
 int eight = 0;  
 
              //            12v on/off       |        12v on/off       | sound
              //      1  2  3  4  5  6  7  8   1  2  3  4  5  6  7  8  | 1  2
volatile char C[18] = {0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0,   0, 0};
           //C[#]     0, 1, 2, 3, 4, 5, 6, 7,  8, 9,10 11,12,13,14,15,  16,17
           
//C[16] trigger receiver to return data       
//C[17] master code value in transmitter 

         
volatile int servo = 0;  // what servo is selected on LCD                 
volatile int bd = 0; //trigger bind event

//----------------[cogs]----------------------------------------------

int *cog1;
void transmitterCog();    //2.4ghz send data to receiver
int *cog2;
void joystickCog();    //ADC MCP3208
int *cog3;
void servoCog();       //send servo position to screen





//-----------[subroutines]--------------------------------------------
void master();
void bind();
void receiverRx();
void keypad(); //receive names and storage address from lcd

void buttons(); //LC12S receive button press from screen

void b2();//JDY-40
void buttons2(); //JDY-40 receive button press from screen

void servodirection();
void savetrim();
void load1trims();


//-----------------------------------------------------------------


int main()
{
  

print("INITIALIZING\n");

//set servo positions to 1500/neutral  
servo1 = 1500;
servo2 = 1500;
servo3 = 1500;
servo4 = 1500;
servo5 = 1500;
servo6 = 1500;
servo7 = 1500;
servo8 = 1500; 
 
//LC12S SET pin
high(10); 

//pins for JDY-40
high(11);
high(12);
high(13);
high(14);
high(15);
high(16);
high(17);
high(18);
  
  
  

                            // RX-TX  
   transceiver = fdserial_open(0, 1, 0, 9600);     // p0-p1  transmiter to receiver
     pause(100); 
                    // RX-TX 
   lcd = fdserial_open(2, 3, 0, 9600);          // p2-p3  transmiter to screen
     pause(100);

   JDY40 = fdserial_open(8, 9, 0, 9600);          // p2-p3  transmiter to screen
     pause(100);  
     
     
     
     
//simpleterm_close();  
  
     cog1 = cog_run(transmitterCog, 128);   
  pause(500);      
  
     cog2 = cog_run(joystickCog, 128);   
  pause(500);   
  
     cog3 = cog_run(servoCog, 128);   
  pause(500); 
  
   
Sign In or Register to comment.