Show Posts
Pages: [1]
1  Using Arduino / Project Guidance / Re: arduino autorange ohmmeter on: December 10, 2013, 07:41:39 am
i have been reading up on current mirrors and i am still not fully sure what i need to do.



your talking about using a circuit like this, and i think, between Q2 and RE is where i should take analogRead()

am i on there right track?

why would i use SMD rather then a something i can solder with out a reflow or a microscope?

why pnp rather then npn or mosfet?


the Wilson current mirror that you linked to uses three npn transistors. i am getting a little lost in the math of how to solve for load.

i understand that i set current with R1. i have the unknown R between the collector of Q2 and ground. then analogRead at  Load
Code:
float=(5.0/1023.0)/(setAmps)
  am i understanding it right?

2  Using Arduino / Project Guidance / Re: arduino autorange ohmmeter on: December 08, 2013, 07:08:52 pm
i have never used a current mirror before. i just googled it but im not sure i understand how it works. if the left side has 5v at 50mA and the right side has ?v at 50mA? so the so the left side changes the resistances of the right transister to keep the apms the same??

i will have to find some transisters and make one so i can put a volt meter to it and see what it does.

but please, is this how your are talking about taking the reading?
3  Using Arduino / Project Guidance / arduino autorange ohmmeter on: December 08, 2013, 04:00:25 pm
i'm trying to make a ohmmeter with an arduino and i'm having a program making it auto range. i have been trying it a few different ways, both on the hardwear side and in the code but i cant seem to make any head way.
i have some diodes(1n4148 and have tried 1n4003) in series with my contral resisters. im using a voltage devider with R1 as my constant and the lower resister is what im putting between leads with analogRead delow the diode.

now A1 is telling me, with a 6k7 as R6 ohm is .057v, 1299.4350ohm, range 2, analog pin0 115
that all seems a little random to me. i know the forword voltage of the diode is going to change the reading i get some but going to a different restister just seems to give a nother random reading. 

does any one know another approach to this?

Code:
  // _____
  // - | _R1__ | - VCC
  // AnalogPin - '_____
  // '- | _R2__ | - GND

  // R2 = resistance to be measured

int AnalogPin = 0;     // potentiometer wiper (middle terminal) connected to analog pin 3
int Alog1;
int Alog2;
int Alog3;
int Alog4;
int Alog5;

                       // outside leads to ground and +5V
int raw = 0;           // variable to store the raw input value
int Vin = 5;           // variable to store the input voltage
float Vout = 0;        // variable to store the output voltage
float R1 = 10;         // variable to store the R1 value
float R2 = 0;          // variable to store the R2 value
float buffer = 0;      // buffer variable for calculation
int range = 200;


  void setup ()
  {
  Serial.begin (9600);
  Serial.println ("Measure resistance");
  Serial.println ();
  }

  void loop ()
  {
digitalWrite(9, LOW);
digitalWrite(10, LOW);
digitalWrite(11, LOW);
digitalWrite(12, LOW);
range = 0;
R1 =1000000;//1g ohm
digitalWrite(8, HIGH);
raw = analogRead(AnalogPin);

if(raw < 100){
digitalWrite(8, LOW);
  digitalWrite(9, HIGH);
raw = analogRead(AnalogPin);
range = 1;
R1 =100000;//100k ohm
  }

if(raw < 100){
digitalWrite(9, LOW);
  digitalWrite(10, HIGH);
raw = analogRead(AnalogPin);
range = 2;
R1 =10000;//10k ohm
  }

if(raw < 100){
digitalWrite(10, LOW);
  digitalWrite(11, HIGH);
raw = analogRead(AnalogPin);
range = 3;
R1 =1000;//1k ohm
  }

if(raw < 100){
digitalWrite(11, LOW);
  digitalWrite(12, HIGH);
raw = analogRead(AnalogPin);
range = 4;
R1 =100;//100 ohm
  }
Alog1 = analogRead(1);
Alog2 = analogRead(2);
Alog3 = analogRead(3);
Alog4 = analogRead(4);
Alog5 = analogRead(5);




  Vout = (5.0 / 1000.0) * raw;
  buffer = (Vin / Vout) - 1;
  R2 = (R1 / buffer);

  Serial.print("Voltage: ");      //
  Serial.println(Vout);           // Outputs the information
  Serial.print ("resistance ");
  Serial.print (R2, DEC);
  Serial.println (" ohm."); 
  Serial.print ("range: ");
  Serial.println(range, 1);
  Serial.print ("analogPin: ");
  Serial.println (raw, DEC);
  Serial.print ("Alog1: ");
  Serial.println (Alog1, DEC);
  Serial.print ("Alog2: ");
  Serial.println (Alog2, DEC);
  Serial.print ("Alog3: ");
  Serial.println (Alog3, DEC);
  Serial.print ("Alog4: ");
  Serial.println (Alog4, DEC);
  Serial.print ("Alog5: ");
  Serial.println (Alog5, DEC);
  Serial.println ("**************************");
  delay (3000);


  }

4  Using Arduino / Programming Questions / Re: help with the HID.cpp on: November 23, 2012, 05:08:54 am
the snip from the USBAPI.h

Code:
//================================================================================
//================================================================================
// Consumer_
//added as Consumer Devices
#define Key_PLAY 0xcd // play/pause
#define Key_VOLUME_UP 0xe9 // volume up
#define Key_VOLUME_DOWN 0xea // volume down
#define Key_NEXT 0xb5 // next track
#define Key_PREVIOUS 0xb6 // previous track
#define Key_MUTE 0xec // mute
#define key_STOP 0xcc    // stop


class Consumer_
{
private:
uint8_t _buttons;
void buttons(uint8_t b);
public:
Consumer_(void);
void begin(void);
void end(void);
void send(byte keyStroke, byte modifiers);
};
extern Consumer_ Consumer;
5  Using Arduino / Programming Questions / Re: help with the HID.cpp on: November 23, 2012, 05:07:26 am
my HID

Code:


Mouse_ Mouse;
Keyboard_ Keyboard;
Consumer_ Consumer;
Gamepad_ Gamepad;
//================================================================================
//================================================================================


//(Consumer Devices)
    0x05, 0x01,                    // USAGE_PAGE (Generic Desktop)
    0x09, 0x06,                    // USAGE (Keyboard)
    0xa1, 0x01,                    // COLLECTION (Application)
    0x05, 0x0c,                    //   USAGE_PAGE (Consumer Devices)
    0x09, 0xcd,                    //   play/pause
    0x09, 0xe9,                    //   volume up
    0x09, 0xea,                    //   volume down
    0x09, 0xb5,                    //   next track
    0x09, 0xb6,                    //   previous track
    0x09, 0xec,                    //   mute
    0x15, 0x00,                    //   LOGICAL_MINIMUM (0)
    0x25, 0x01,                    //   LOGICAL_MAXIMUM (1)
    0x95, 0x06,                    //   REPORT_COUNT (6)
    0x75, 0x01,                    //   REPORT_SIZE (1)
    0x81, 0x02,                    // INPUT (Data,Var,Abs)
    0xc0                           // END_COLLECTION
/*
//(Consumer Devices)
    0x05, 0x01,                    // USAGE_PAGE (Generic Desktop)
    0x09, 0x06,                    // USAGE (Keyboard)
    0xa1, 0x01,                    // COLLECTION (Application)
    0x05, 0x0c,                    //   USAGE_PAGE (Consumer Devices)
  //0x85, 0x01,
    0x15, 0x00,                    //   LOGICAL_MINIMUM (0)
    0x25, 0x01,                    //   LOGICAL_MAXIMUM (1)
    0x95, 0x06,                    //   REPORT_COUNT (2)
    0x75, 0x01,                    //   REPORT_SIZE (1)
    0x81, 0x02,                    // INPUT (Data,Var,Abs)
   /*
    0x05, 0x07,                    //   USAGE_PAGE (Keyboard)
    0x95, 0x01,                    //   REPORT_COUNT (simultaneous keystrokes)
    0x75, 0x08,                    //   REPORT_SIZE (8)
    0x25, 0x65,                    //   LOGICAL_MAXIMUM (101)
    0x19, 0x00,                    //   USAGE_MINIMUM (Reserved (no event indicated))
    0x29, 0x65,                    //   USAGE_MAXIMUM (Keyboard Application)
    0x81, 0x00,                    //   INPUT (Data,Ary,Abs)
*/
    //0xc0,                          // END_COLLECTION


// Gamepad
    0x05, 0x01,                    // USAGE_PAGE (Generic Desktop)
    0x09, 0x05,                    // USAGE (Game Pad)
    0xa1, 0x01,                    // COLLECTION (Application)
    0xa1, 0x00,                    //   COLLECTION (Physical)
    0x85, 0x03,                    //     REPORT_ID (3)
    0x05, 0x09,                    //     USAGE_PAGE (Button)
    0x19, 0x01,                    //     USAGE_MINIMUM (Button 1)
    0x29, 0x08,                    //     USAGE_MAXIMUM (Button 8)
    0x15, 0x00,                    //     LOGICAL_MINIMUM (0)
    0x25, 0x01,                    //     LOGICAL_MAXIMUM (1)
    0x95, 0x04,                    //     REPORT_COUNT (4)
    0x75, 0x01,                    //     REPORT_SIZE (1)
    0x81, 0x02,                    //     INPUT (Data,Var,Abs)
    0x05, 0x01,                    //     USAGE_PAGE (Generic Desktop)
    0x09, 0x30,                    //     USAGE (X)
    0x09, 0x31,                    //     USAGE (Y)
    0x15, 0xff,                    //     LOGICAL_MINIMUM (-1)
    0x25, 0x01,                    //     LOGICAL_MAXIMUM (1)
    0x95, 0x02,                    //     REPORT_COUNT (2)
    0x75, 0x02,                    //     REPORT_SIZE (2)
    0x81, 0x02,                    //     INPUT (Data,Var,Abs)
    0xc0,                          //   END_COLLECTION
    0xc0                           // END_COLLECTION

#if RAWHID_ENABLED
// RAW HID
0x06, LSB(RAWHID_USAGE_PAGE), MSB(RAWHID_USAGE_PAGE), // 30
0x0A, LSB(RAWHID_USAGE), MSB(RAWHID_USAGE),

0xA1, 0x01, // Collection 0x01
    0x85, 0x03, // REPORT_ID (3)
0x75, 0x08, // report size = 8 bits
0x15, 0x00, // logical minimum = 0
0x26, 0xFF, 0x00, // logical maximum = 255

0x95, 64, // report count TX
0x09, 0x01, // usage
0x81, 0x02, // Input (array)

0x95, 64, // report count RX
0x09, 0x02, // usage
0x91, 0x02, // Output (array)
0xC0 // end collection
#endif
};

extern const HIDDescriptor _hidInterface PROGMEM;
const HIDDescriptor _hidInterface =
{
D_INTERFACE(HID_INTERFACE,1,3,0,0),
D_HIDREPORT(sizeof(_hidReportDescriptor)),
D_ENDPOINT(USB_ENDPOINT_IN (HID_ENDPOINT_INT),USB_ENDPOINT_TYPE_INTERRUPT,0x40,0x01)
};




//================================================================================
//================================================================================
// Driver

u8 _hid_protocol = 1;
u8 _hid_idle = 1;

#define WEAK __attribute__ ((weak))

int WEAK HID_GetInterface(u8* interfaceNum)
{
interfaceNum[0] += 1; // uses 1
return USB_SendControl(TRANSFER_PGM,&_hidInterface,sizeof(_hidInterface));
}

int WEAK HID_GetDescriptor(int i)
{
return USB_SendControl(TRANSFER_PGM,_hidReportDescriptor,sizeof(_hidReportDescriptor));
}

void WEAK HID_SendReport(u8 id, const void* data, int len)
{
USB_Send(HID_TX, &id, 1);
USB_Send(HID_TX | TRANSFER_RELEASE,data,len);
}

bool WEAK HID_Setup(Setup& setup)
{
u8 r = setup.bRequest;
u8 requestType = setup.bmRequestType;
if (REQUEST_DEVICETOHOST_CLASS_INTERFACE == requestType)
{
if (HID_GET_REPORT == r)
{
//HID_GetReport();
return true;
}
if (HID_GET_PROTOCOL == r)
{
//Send8(_hid_protocol); // TODO
return true;
}
}

if (REQUEST_HOSTTODEVICE_CLASS_INTERFACE == requestType)
{
if (HID_SET_PROTOCOL == r)
{
_hid_protocol = setup.wValueL;
return true;
}

if (HID_SET_IDLE == r)
{
_hid_idle = setup.wValueL;
return true;
}
}
return false;
}

//================================================================================
//================================================================================
// Mouse

Mouse_::Mouse_(void) : _buttons(0)
{
}

void Mouse_::begin(void)
{
}

void Mouse_::end(void)
{
}

void Mouse_::click(uint8_t b)
{
_buttons = b;
move(0,0,0);
_buttons = 0;
move(0,0,0);
}

void Mouse_::move(signed char x, signed char y, signed char wheel)
{
u8 m[4];
m[0] = _buttons;
m[1] = x;
m[2] = y;
m[3] = wheel;
HID_SendReport(1,m,4);
}

void Mouse_::buttons(uint8_t b)
{
if (b != _buttons)
{
_buttons = b;
move(0,0,0);
}
}

void Mouse_::press(uint8_t b)
{
buttons(_buttons | b);
}

void Mouse_::release(uint8_t b)
{
buttons(_buttons & ~b);
}

bool Mouse_::isPressed(uint8_t b)
{
if ((b & _buttons) > 0)
return true;
return false;
}


//================================================================================
//================================================================================
// Consumer

Consumer_::Consumer_(void)
{
}

void Consumer_::begin(void)
{
}

void Consumer_::end(void)
{
}

/*
void Consumer_::press(uint8_t b)
{
buttons(_buttons | b);
}

void Consumer_::release(uint8_t b)
{
buttons(_buttons & ~b);
}

bool Consumer_::isPressed(uint8_t b)
{
if ((b & _buttons) > 0)

return true;
return false;
}
*/
void Consumer_::send(BYTE keyStroke, BYTE modifiers) {

while (!usbInterruptIsReady()) {
// Note: We wait until we can send keystroke
//       so we know the previous keystroke was
//       sent.
}

memset(reportBuffer, 0, sizeof(reportBuffer));

reportBuffer[0] = keyStroke;

usbSetInterrupt(reportBuffer, sizeof(reportBuffer));

while (!usbInterruptIsReady()) {
// Note: We wait until we can send keystroke
//       so we know the previous keystroke was
//       sent.
}

// This stops endlessly repeating keystrokes:
memset(reportBuffer, 0, sizeof(reportBuffer));
usbSetInterrupt(reportBuffer, sizeof(reportBuffer));

}



//================================================================================
//================================================================================
// Gamepad

Gamepad_::Gamepad_(void) : _buttons(0)
{
}

void Gamepad_::begin(void)
{
}

void Gamepad_::end(void)
{
}

void Gamepad_::press(uint8_t b)
{
_buttons |= b;
HID_SendReport(3,&_buttons,1);
}

void Gamepad_::release(uint8_t b)
{
_buttons &= ~b;
HID_SendReport(3,&_buttons,1);
}

bool Gamepad_::isPressed(uint8_t b)
{
if ((b & _buttons) > 0)
return true;
return false;
}

i trimmed it to fit in the post.
6  Using Arduino / Programming Questions / help with the HID.cpp on: November 23, 2012, 05:03:14 am
i have been searching for an answer to this but haven't found a way to make it work.

i am trying to add the Consumer Devices functions to the HID lib(play/pause...and such)

i found this http://blog.derouineau.fr/category/technique/arduino/, its for the old V_usb lib so i think i am just not understanding how to integrate it in to the HID.cpp/USBAPT.h in arduino 1.0

its now giving me this error when i tried Consumer.send(smiley-cool;
Code:
sketch_nov22a.cpp: In function ‘void loop()’:
sketch_nov22a.cpp:43:20: error: no matching function for call to ‘Consumer_::send(int)’
sketch_nov22a.cpp:43:20: note: candidate is:
In file included from /usr/share/arduino/hardware/arduino/cores/arduino/HardwareSerial.h:66:0,
                 from /usr/share/arduino/hardware/arduino/cores/arduino/Arduino.h:193,
                 from sketch_nov22a.cpp:2:
/usr/share/arduino/hardware/arduino/cores/arduino/USBAPI.h:93:7: note: void Consumer_::send(byte, byte)
/usr/share/arduino/hardware/arduino/cores/arduino/USBAPI.h:93:7: note:   candidate expects 2 arguments, 1 provided

i have been at this for a week and dont seem to be making any headway
7  Using Arduino / Programming Questions / Re: help with Printf_P(PSTR()) on: November 26, 2011, 05:12:23 pm
ok im sry i still am not able to print volts to the glcd. it prints to the serial monitor just fine. i just dont understand.

i googled println and did some reading on that and got "stat" printing to the glcd like it should.

here is my code as far as i have it now

Code:
// A simple sketch to read GPS data and parse the $GPRMC string
// see http://www.ladyada.net/make/gpsshield for more info
// GPS parser for 406a
#include "glcd.h"
#define BUFFSIZ 90 //90 plenty big
#include "fonts/allFonts.h"
char buffer[BUFFSIZ];

char *parseptr;

char buffidx;

uint8_t hour, minute, second, year, month, date;

//uint32_t latitude, longitude;

uint8_t groundspeed, trackangle;

//char latdir, longdir;

char status;

unsigned int tachometer;

float volts = 0.0;


//------------------------------------------------------------------------------
//-----------------------------------pin defined--------------------------------
//------------------------------------------------------------------------------

const int voltpin = 1;

//******************************************************************************
//************************************setup*************************************
//******************************************************************************


void setup()

{ pinMode(voltpin, INPUT);//need to see the voltage of the battory


GLCD.Init(NON_INVERTED);
GLCD.ClearScreen();
GLCD.SelectFont(System5x7);
GLCD.Printf_P(PSTR("bike speedo test"));

   Serial.begin(9600);

   Serial1.begin(4800);

delay(3000);

GLCD.ClearScreen();
 }

gText t1 = gText(10,0, 3,1, fixednums15x31); // used for the speedometer

gText t2 = gText(10,29, 5,1, fixednums15x31); // used for the tachometer

gText t3 = gText(60,0, 8,1, SystemFont5x7); //used for time

gText t4 = gText(60,8, 8,1, SystemFont5x7); //used for date

gText t5 = gText(60,16, 1,1, SystemFont5x7); //used for sat. lock

gText t6 = gText(68,16, 6,1, SystemFont5x7); //used for the voltage of the battery





//***********************************************************************************
//***************************************start of loop*******************************
//***********************************************************************************

void loop()

{

  uint32_t tmp;


// read the value on analog input
volts = analogRead(voltpin); //5v =317
volts = volts * 5.0; //=1585
volts = volts /1023.0; //=1.549364614
volts = volts * 1.454545455;//=2.253621257

//volts = parsedecimal(parseptr);

//parseptr = strchr(parseptr, '.')+1;


//voltsdec = parsedecimal(parseptr);
 

  //Serial.print("\n\rread: ");

  readline();

 

  // check if $GPRMC (global positioning fixed data)

  if (strncmp(buffer, "$GPRMC",6) == 0) {

   

    // hhmmss time data

    parseptr = buffer+7;

    tmp = parsedecimal(parseptr);

    hour = tmp / 10000;

    minute = (tmp / 100) % 100;

    second = tmp % 100;

if (hour > 05)
{
hour -= (6);
}
   
else if (hour < 05)
{
hour += (18);
}


    parseptr = strchr(parseptr, ',') + 1;


    status = parseptr[0];

    /*
    // grab latitude & long data

    // latitude

    parseptr = strchr(parseptr, ',')+1;

    latitude = parsedecimal(parseptr);

    if (latitude != 0) {

      latitude *= 10000;

      parseptr = strchr(parseptr, '.')+1;

      latitude += parsedecimal(parseptr);

    }

    parseptr = strchr(parseptr, ',') + 1;

    // read latitude N/S data

    if (parseptr[0] != ',') {

      latdir = parseptr[0];

    }

   

    //Serial.println(latdir);

   

    // longitude

    parseptr = strchr(parseptr, ',')+1;

    longitude = parsedecimal(parseptr);

    if (longitude != 0) {

      longitude *= 10000;

      parseptr = strchr(parseptr, '.')+1;

      longitude += parsedecimal(parseptr);

    }

    parseptr = strchr(parseptr, ',')+1;

    // read longitude E/W data

    if (parseptr[0] != ',') {

      longdir = parseptr[0];

    }

    */



parseptr = strchr(parseptr, ',') + 1;
parseptr = strchr(parseptr, ',') + 1;
parseptr = strchr(parseptr, ',') + 1;
parseptr = strchr(parseptr, ',') + 1;

    // groundspeed

    parseptr = strchr(parseptr, ',')+1;

    groundspeed = parsedecimal(parseptr);
   
parseptr = strchr(parseptr, '.')+1;

groundspeed += ((parsedecimal(parseptr))/100);

    groundspeed *=(1.1507);

    // track angle

    parseptr = strchr(parseptr, ',')+1;

    trackangle = parsedecimal(parseptr);


    // date

    parseptr = strchr(parseptr, ',')+1;

    tmp = parsedecimal(parseptr);

    date = tmp / 10000;

    month = (tmp / 100) % 100;

    year = tmp % 100;

//***********************************************************************
//************************start of printing data*************************
//***********************************************************************

// the status connection to the satalites goes here
   
Serial.print("\nStatus: ");
Serial.print(status);
    t5.CursorToXY(0,0);
t5.Printf_P(PSTR("%01c"),status);//something is wrong here


// speed is printed from here

    Serial.print("\nSpeed: ");
    Serial.print(groundspeed, DEC);

    t1.CursorToXY(0,0);
t1.Printf_P(PSTR("%3d"),groundspeed);


//the data for the tach is printed here
    Serial.print("\ntach: ");
    Serial.print(tachometer);
t2.CursorToXY(0,0);
if (tachometer <= 10300)
{
t2.Printf_P(PSTR("%5d"),tachometer);
}
else if(tachometer >= 10301)
{
t2.SetFontColor(WHITE);
t2.ClearArea();
t2.Printf_P(PSTR("%5d"),tachometer);
}
 


// your heading in degrees is printed from here   
    Serial.print("\nTracking angle: ");
    Serial.print(trackangle, DEC);
   


// the data for the battery voltage
Serial.print("\nVoltage: ");
Serial.print(volts, DEC);
    t6.CursorToXY(0,0);
t6.println(volts, DEC);
t6.Printf_P(PSTR("V"));



// time of day is printed from here   
    Serial.print("\nTime: ");

    Serial.print(hour, DEC); Serial.print(':');

    Serial.print(minute, DEC); Serial.print(':');

    Serial.println(second, DEC);

t3.CursorToXY(0,0);
t3.Printf("%02d:%02d:%02d",hour,minute,second);

// the date is printed form here
    Serial.print("Date: ");

    Serial.print(month, DEC); Serial.print('/');

    Serial.print(date, DEC); Serial.print('/');

    Serial.println(year, DEC);

t4.Printf("%02d/%02d/%02d", month, date, year);



    /*

    Serial.print("Lat: ");

    if (latdir == 'N')

       Serial.print('+');

    else if (latdir == 'S')

       Serial.print('-');



    Serial.print(latitude/10000000, DEC); Serial.print('\°', BYTE); Serial.print(' ');

    Serial.print((latitude/10000)%100, DEC); Serial.print('\''); Serial.print(' ');

    Serial.print((latitude%10000)*6/1000, DEC); Serial.print('.');

    Serial.print(((latitude%10000)*6/10)%100, DEC); Serial.println('"');

   

    Serial.print("Long: ");

    if (longdir == 'E')

       Serial.print('+');

    else if (longdir == 'W')

       Serial.print('-');

    Serial.print(longitude/10000000, DEC); Serial.print('\°', BYTE); Serial.print(' ');

    Serial.print((longitude/10000)%100, DEC); Serial.print('\''); Serial.print(' ');

    Serial.print((longitude%10000)*6/1000, DEC); Serial.print('.');

    Serial.print(((longitude%10000)*6/10)%100, DEC); Serial.println('"');

   */

  }

  //Serial.println(buffer);

}



uint32_t parsedecimal(char *str) {

  uint32_t d = 0;

 

  while (str[0] != 0) {

   if ((str[0] > '9') || (str[0] < '0'))

     return d;

   d *= 10;

   d += str[0] - '0';

   str++;

  }

  return d;

}



void readline(void) {

  char c;

 

  buffidx = 0; // start at begninning

  while (1) {

      c=Serial1.read();

      if (c == -1)

        continue;

      Serial.print(c);

      if (c == '\n')

        continue;

      if ((buffidx == BUFFSIZ-1) || (c == '\r')) {

        buffer[buffidx] = 0;

        return;

      }

      buffer[buffidx++]= c;

  }

}
8  Using Arduino / Programming Questions / Re: help with Printf_P(PSTR()) on: November 26, 2011, 12:31:44 pm
t5 and t6 are text areas i have defined to the glcd.

Code:
gText t1 = gText(10,0, 3,1, fixednums15x31); // used for the speedometer


gText t2 = gText(10,29, 5,1, fixednums15x31); // used for the tachometer

gText t3 = gText(60,0, 8,1, SystemFont5x7); //used for time

gText t4 = gText(60,8, 8,1, SystemFont5x7); //used for date

gText t5 = gText(60,16, 1,1, SystemFont5x7); //used for sat. lock

gText t6 = gText(68,16, 5,1, SystemFont5x7); //used for the voltage of the battery

"volts" is defined as
Code:
unsigned int volts;

but i tried it as a float however, that did not change anything so i changed it back since i am trying to save as much RAM as i can

"status" is defined as
Code:
char status;

t6.Printf_P(PSTR("%04d"),volts);t6.Printf_P(PSTR("V")); //----------> is showing up on the glcd as "0001V". i am trying to make it show up as "01.2V"

t5.Printf_P(PSTR("%01S"),status); //-----------is not showing anything at all
Serial.print(status);//----------> is showing "V" right now


i am not really sure what part of the code you need to see. i thoguht where i used "%04d" and "%01S" i should be using something else. i cant seem to find some where that says what "%04d" , "%02S" and "%02s" are used for and the difference between them. really i have been looking
9  Using Arduino / Programming Questions / help with Printf_P(PSTR()) on: November 26, 2011, 11:28:12 am
i am trying to print to an glcd using the glcd lib but i am having 2 problems that i have been googling for days and cant find the answer.

1.)
i am wanting to print either a V or an A to tell if a gps has a lock. the code i am trying to use is...
Code:
Serial.print("\nStatus: ");
Serial.print(status);
    t5.CursorToXY(0,0);
t5.Printf_P(PSTR("%01S"),status);


2.)
i am printing a value of less then 16.00 but i want it to show ##.#V rather then just as ####V as it it showing up now.
Code:
// the data for the battery voltage
Serial.print("\nVoltage: ");
Serial.print(volts);
    t6.CursorToXY(0,0);
t6.Printf_P(PSTR("%04d"),volts);t6.Printf_P(PSTR("V"));


10  Using Arduino / Project Guidance / Re: Arduino for E-trigger on: February 07, 2011, 05:50:21 pm
ok i think im on to something here. have a look at this code and tell me if im on the right track

Code:
/*
 
 
 The circuit:
 * NPN attached to pin 13
 * pushbutton attached to pin 1 from +5V
 * pushbutton attached to pin 2 from +5V
 * pushbutton attached to pin 3 from +5V
 * pushbutton attached to pin 4 from +5V
 * pushbutton attached to pin 5 from +5V
 * 10K resistor attached to pin 1 from ground
 * 10K resistor attached to pin 2 from ground
 * 10K resistor attached to pin 3 from ground
 * 10K resistor attached to pin 4 from ground
 * 10K resistor attached to pin 5 from ground
 
 * Note: on most Arduinos there is already an LED on the board
 attached to pin 13.
 
 
 created 2005
 by DojoDave <http://www.0j0.org>
 modified 07 Feb 2011
 by eliofall
 
 This example code is in the public domain.
 */

// constants won't change. They're used here to
// set pin numbers:
const int trigger      = 1;
const int safety       = 2;
const int semi         = 3;
const int burst         = 4;
const int full         = 5;    
const int ledPin     = 13;      // goes to an 2n2222 to turn on the led & selonoid

// variables will change:
int triggerState = 0;
int safetyState = 0;
int semiState = 0;
int burstState = 0;
int fullState = 0;

void setup() {
  pinMode(ledPin , OUTPUT);      
  pinMode(frigger , INPUT);
  pinMode(safety , INPUT);
  pinMode(semi , INPUT);
  pinMode(burst , INPUT);
  pinMode(full , INPUT);  
}

void loop(){
  // read the state of the pushbutton value:
  triggerState = digitalRead(trigger);
  safetyState = digitalRead(safety);
  semiState = digitalRead(semi);
  burstState = digitalRead(burst);
  fullState = digitalRead(full);

  // check if you hand is on the grip, where the selecter is and if youve pulled the trigger.
  if (triggerState == HIGH)
  and (safetyState == HIGH)
  and (semiState == LOW)
  and (burstState == LOW)
  and (fullState == HIGH) {
 void loop() {    
    digitalWrite(ledPin, HIGH);
    delay(10);
    digitalWrite(ledpin, LOW);    
    delay(70);  
  }
}
  else {
    // turn LED off:
    digitalWrite(ledPin, LOW);
  }
}

 // check if you hand is on the grip, where the selecter is and if youve pulled the trigger.
  if (triggerState == HIGH)
  and (safetyState == HIGH)
  and (semiState == LOW)
  and (burstState == HIGH)
  and (fullState == LOW) {
 digitalWrite() {    
    digitalWrite(ledPin, HIGH);
    delay(10);
    digitalWrite(ledpin, LOW);    
    delay(70);  
    digitalWrite(ledPin, HIGH);
    delay(10);
    digitalWrite(ledpin, LOW);    
    delay(70);  
    digitalWrite(ledPin, HIGH);
    delay(10);
    digitalWrite(ledpin, LOW);    
    delay(70);  
  
}
  else {
    // turn LED off:
    digitalWrite(ledPin, LOW);
  }
}

 // check if you hand is on the grip, where the selecter is and if youve pulled the trigger.
  if (triggerState == HIGH)
  and (safetyState == HIGH)
  and (semiState == LOW)
  and (burstState == HIGH)
  and (fullState == LOW) {
 digitalWrite() {    
    digitalWrite(ledPin, HIGH);
    delay(10);
    digitalWrite(ledpin, LOW);    
    delay(70);
  
}
11  Using Arduino / Project Guidance / Arduino for E-trigger on: February 07, 2011, 01:42:32 am
ok i have been doing some googling on this for a few days, i asked over on a pb forum and now i think i should ask here. i just ask that you go easy on me.

ok i am looking to make a electronic trigger for a paintball guns based on open source.

there are a few things i want this E-trigger to do and not do.

it should be noted im a machinist and dont know anything about programing

i'm only wanting 900 RPM or 15 BPS.

i want to have a 3way switch so i can change from semi-, burst and full(no ramping, no safety)

i want to have a safety in the hand grip (like in a 1911) so if your hand is not on it, the gun can not fire.

the solenoid will be controlled via NPN and a led to show when its triping.

well thats all im wanting out of this. now its just a matter of getting down to whats the best way to do this.

1. i was thinking on the grip safety, having that as the power switch. but i dont know how long of a bootup time the arduino has. if it is less then .5sec. then i could get away with doing it that way. is it is longer then that it would be in series with the solenoid.

2. the selector switch i was thinking of using a rotary switch. on the other side i was thinking using different resisters going to an input pin. so 1kohm+input.pin=semi and 3.3kohm+input.pin=burst

so if input.pin=3.3kohm then for one trigger pull, the solenoid will trip, wait 0.7sec. then trip again, and wait .07sec. then again trip, and last wait .07sec. once more. however if the trigger is pulled a 2nd time before the end of the firing cycle, it is ignored.

so how am i thinking the right way on how to set it up?  

how would i go about programing this?
Pages: [1]