Show Posts
Pages: [1] 2 3 ... 10
1  Forum 2005-2010 (read only) / Syntax & Programs / Re: LCD "Bigfont" Numbers over 2 or 4 lines on: July 01, 2009, 10:40:48 am
Ok, I hate LCD4Bit, here's some code to do it with LiquidCrystal:

Quote

#include <LiquidCrystal.h>
LiquidCrystal lcd(2, 3, 4, 5, 6, 7, smiley-cool;

byte custchar[8][8] = {
  {
    B11111,
    B11111,
    B11111,
    B00000,
    B00000,
    B00000,
    B00000,
    B00000
  }, {
    B00000,
    B00000,
    B00000,
    B00000,
    B00000,
    B11111,
    B11111,
    B11111
  }, {
    B11111,
    B11111,
    B11111,
    B00000,
    B00000,
    B11111,
    B11111,
    B11111
  }, {
    B00000,
    B00000,
    B00000,
    B00000,
    B00000,
    B01110,
    B01110,
    B01110
  }, {
    B00000,
    B00000,
    B00000,
    B01110,
    B01110,
    B01110,
    B00000,
    B00000
  }, {
    B00000,
    B00000,
    B00000,
    B00000,
    B00000,
    B00000,
    B00000,
    B00000
  }, {
    B00000,
    B00000,
    B00000,
    B00000,
    B00000,
    B00000,
    B00000,
    B00000
  }, {
    B00000,
    B00000,
    B00000,
    B00000,
    B00000,
    B00000,
    B00000,
    B00000
  }
};

byte bignums[10][2][3] = {
  {
    {255, 0, 255},
    {255, 1, 255}
  },{
    {0, 255, 254},
    {1, 255, 1}
  },{
    {2, 2, 255},
    {255, 1, 1}
  },{
    {0, 2, 255},
    {1, 1, 255}
  },{
    {255, 1, 255},
    {254, 254, 255}
  },{
    {255, 2, 2},
    {1, 1, 255}
  },{
    {255, 2, 2},
    {255, 1, 255}
  },{
    {0, 0, 255},
    {254, 255, 254}
  },{
    {255, 2, 255},
    {255, 1, 255}
  },{
    {255, 2, 255},
    {254, 254, 255}
  }
};

void loadchars() {
  lcd.command(64);
  for (int i = 0; i < 8; i++)
    for (int j = 0; j < 8; j++)
      lcd.write(custchar[j]);
  lcd.home();
}

void printbigchar(byte digit, byte col, byte row, byte symbol = 0) {
  if (digit > 9) return;
  for (int i = 0; i < 2; i++) {
    lcd.setCursor(col, row + i);
    for (int j = 0; j < 3; j++) {
      lcd.write(bignums[digit][j]);
    }
    lcd.write(254);
  }
  if (symbol == 1) {
    lcd.setCursor(col + 3, row + 1);
    lcd.write(3);
  } else if (symbol == 2) {
    lcd.setCursor(col + 3, row);
    lcd.write(4);
    lcd.setCursor(col + 3, row + 1);
    lcd.write(4);
  }
  
  lcd.setCursor(col + 4, row);
}

void setup() {
  pinMode(13, OUTPUT);
  loadchars();
  digitalWrite(13, 1);
  
  printbigchar(0, 0, 0);
  printbigchar(1, 4, 0);
  printbigchar(2, 8, 0);
  printbigchar(3, 12, 0);
  printbigchar(4, 16, 0, 1);
  printbigchar(5, 0, 2);
  printbigchar(6, 4, 2);
  printbigchar(7, 8, 2);
  printbigchar(8, 12, 2);
  printbigchar(9, 16, 2, 2);
}

void loop() {}
2  Forum 2005-2010 (read only) / Syntax & Programs / Re: LCD "Bigfont" Numbers over 2 or 4 lines on: July 01, 2009, 04:21:17 am
Where is the declaration for LcdUploadUdef5x8()?
3  Forum 2005-2010 (read only) / Syntax & Programs / Re: force a value to 3 digits on: July 22, 2009, 02:26:22 pm
Here's a padprint function from one of my sketches that could be easily adapted:

Quote
void padprint(int number, int chars) {
  for (int i = pow(10, chars - 1); number <= i - 1; i /= 10) Serial.print("0");
  Serial.print(number);
}
4  Forum 2005-2010 (read only) / Development / Re: CapSense Library on: March 18, 2010, 10:05:27 am
The tqfp package has two additional analog pins (6 and 7), which do not work as digital pins, but last I checked, the pro mini does not break out these pins. It should be possible to use these for capacitive sensor inputs, but not using the capsense library.
5  Forum 2005-2010 (read only) / Development / Re: CapSense Library on: March 18, 2010, 09:36:33 am
Analog ports 0-5 are also mapped to digital 14-19.
6  Forum 2005-2010 (read only) / Development / Re: CapSense Library on: July 21, 2009, 02:00:36 pm
You don't need to go looking for stained glass supplies, I got mine from Mouser: http://www.mouser.com/Search/ProductDetail.aspx?R=1194-1/2%22x36ydvirtualkey51730000virtualkey517-1194-1/2
7  Forum 2005-2010 (read only) / Development / Re: CapSense Library on: July 21, 2009, 01:03:00 pm
I ended up writing my own code instead of using the library, but here's a test project I did with a linear series of 8 capacitive sensors. They are made from 1"x.5" pieces of copper tape. I stuck them to graph paper so that I could align and space them precisely. I then added a strip and a series of pads across the top so that I could mount an SMD LED for each sensor, and added a backing and border to connect to ground. It works extremely well when I touch the pads directly, and it also works through a sheet of paper or plastic, though I have to press a little harder.


8  Forum 2005-2010 (read only) / Development / Re: CapSense Library on: June 03, 2009, 11:33:30 am
Yeah, I've already got some copper tape, but I was thinking that a more resistive material would be better, like the resistive material that I assume is used in a slide pot. This would make the output continuously variable, and wouldn't have the lumps of a series of resistors. I'm not sure exactly how slide-pots are constructed, but you might be able to repurpose one for non-contact operation as a linear capacitive sensor.
9  Forum 2005-2010 (read only) / Development / Re: CapSense Library on: June 03, 2009, 10:48:16 am
Quote
...

Good luck and maybe take a trip to Radio Shack for the proper resistors, or Digikey, if you're miles from RS.

...
Alas, Radioshack can no longer be counted upon to stock such things. The last time I asked for resistors at a Radioshack, the guy behind the counter looked at me as if I was speaking Swahili, then offered me a free cell phone with two-year contract. Granted, the Radioshack in question was in a mall, and my local Radioshack still has fire-starter soldering irons and perfboard, but their hobbyist section is slowly succumbing to consumer-electronics creep as well.

Anyway, I'm considering undertaking a project that would benefit greatly from a capacitive sensor or two. I saw some talk of using multiple resistors for a linear sensor, and I was wondering if anyone had tried putting two of these at right angles to make a simple trackpad. I imagine this would be trickier as the two sensors would probably interfere with one another, but to pull it off an arduino and hand-made sensors would be pretty impressive.
10  Forum 2005-2010 (read only) / Development / Re: How to only require setup() on: May 06, 2009, 11:24:31 am
Why check to see if loop() is defined repeatedly if there is no code that could define it? You're also wasting a cycle or two in each loop if it does exist. The only possible use would be to avoid the program failing (almost certainly silently, as there wouldn't seem to be anywere for the error to go) if loop() deletes itself.

Does it cause Bad Things to happen if main() returns, leaving no code to be executed? I would think that if you don't want to loop, you either want to do that or put the arduino to sleep, rather than burning cycles (and power, and potentially even the chip itself if your thermal regulation is inadequate) by doing nothing in an infinite loop.

Something like this seems more logical to me:

Code:
extern void loop(void) __attribute__((weak));

int main(void) {
  init();
    
  setup();

  if (loop != NULL) for (;;) loop();

  //put sleep code here, in a loop, if running out of code is a Bad Thing

  return 0;
}

I agree with Lefty though, that this seems like a solution seeking a problem (not that I'm not known for coming up with those myself from time to time).

If I had wanted to do this, I would have written loop() to put the arduino to sleep, but depending on how it responds when main() returns, I can see how that might be preferable (although none of the previously-posted code even allows that to happen).
11  Forum 2005-2010 (read only) / Troubleshooting / Re: How to get a stable reference voltage? on: May 20, 2009, 01:10:29 pm
Sweet. I implemented both of those changes and it made a huge difference. Rerouting my ground traces to isolate the analog circuitry from the motor driver with the 5V regulator in the middle gave me almost 8 ohms from one end to the other.

I now get clean enough data from the gyro to make my robot stand for a few seconds using only that data. Now I have to add the accelerometer data back in and figure out this kalman filter stuff...
12  Forum 2005-2010 (read only) / Troubleshooting / Re: How to get a stable reference voltage? on: May 20, 2009, 11:06:14 am
Ah, so you're suggesting that parts of my ground are higher than others. That could be, I suppose...

I haven't done much checking of the voltages with a meter while the motors are running (it's difficult to test the contacts while the robot is trying to run away from you), I've figured out that my reference voltage was changing mostly based on debugging data coming off the USB connection. I did check my voltages to verify, but I probably only used the ground at the ftdi header (for convenience). I've been using my meter mostly for continuity testing while the power is disconnected.
13  Forum 2005-2010 (read only) / Troubleshooting / Re: How to get a stable reference voltage? on: May 20, 2009, 10:48:13 am
Quote
My gut feeling is that your voltages aren't dropping, your ground is rising.

As your motors kick in, the current causes a voltage drop in their ground path causing a slight increase in the "ground" voltage in that path (remember: "There is no such thing as ground").

Consider keeping your motor grounds and analog/digital grounds as separate as possible, right up to the power source.

I suspected it might be a ground issue too, but shouldn't the regulators compensate for that? It's not that the values are spiking (I could fix that with caps), it's a consistent drop. When the ground gets pulled up, pull up the ground pins on the regulators, and they should increase the output voltage to compensate, unless I'm missing something...

Unfortunately, my SN754410 is on a controller board that doesn't make it particularly easy to isolate things, but I'll see what I can do. I wonder if it would help to add a hunk of metal to sink my ground...
14  Forum 2005-2010 (read only) / Troubleshooting / Re: How to get a stable reference voltage? on: May 20, 2009, 10:33:36 am
Quote
If you have a free A/D input, connect it to the gyros vref output.
Then measure rates by comparing the rate outputs against the vref output... it should be (nearly) unaffected by small changes in power supply, since this is the reference the gyro is using internally.

something like...
Code:
#define vrefPin 0
#define xratePin 1
#define yratePin 2

int rawX, rawY;

void Gyro(){
 int ref;
 ref = analogRead(vrefPin);
 rawX = analogRead(xratePin)-ref;
 rawY = analogRead(yratePin)-ref;
}
Of course, THAT'S what that's for. I had tried reading the voltage off of that, but it didn't seem that stable, so I ignored it, but that instability might just be the inverse of the ADC reference instability.

I do have one input unused, I'll have to see about rewiring to make it available...
15  Forum 2005-2010 (read only) / Troubleshooting / How to get a stable reference voltage? on: May 20, 2009, 08:35:59 am
I'm trying to build a robot using the sparkfun IMU 5DOF. This board includes an accelerometer with ratiometric output and a gyro that does not use ratiometric output. I can use the accelerometer just fine, but when my motors kick in, the voltage to the rest of my circuit drops slightly which screws up my reference voltage, making my gyro useless.

My robot is designed to be powered by ~9V from a battery pack, but I've been using an 800 mA wall wart for testing. This voltage feeds both a SN754410 h-bridge for two motors (each of which should draw < 30mA at 9 volts) and a 7805 regulator for the arduino and a few other components. This 5V is dropping slightly when the motors kick in. There is also an MCP1700 3.3v LDO regulator drawing from the 5v that powers the IMU board and is currently also connected to my analog reference (both to increase ADC resolution and to try to stabilize the reference voltage), but this voltage is also dropping enough to screw up my measurements.

What does it take to get a stable reference voltage? I could add an isolated power source just for the IMU and ADC reference, but there must be a better way!
Pages: [1] 2 3 ... 10