Show Posts
Pages: [1] 2 3 4
1  Forum 2005-2010 (read only) / Forum / Merging Similar Topics better categorization on: December 09, 2010, 09:53:30 am
It would be nice to merge similar topics or have more specialized categories. for example I started a keypad discussion While there already was one going, if there were a place for inputs and subtopics such as keypad, wii nunchuck, analog,

a subtopic for LED projects

subtopics for widely used peripherals.


Choices of key words would be nice as well.

people having choices of keywords that would allow people to either use the forum as is, but also have the choice of browsing the different keywords

when there is sufficient interest in a certain topic, a playground wiki page would be a nice addition where people involved in the discussions are encouraged to condense the conversation into a single wiki article. that way when a topic in a discussion gets to be repetitive, people refer others to the proper wiki page so people can get up to speed without someone having to explain things over and over. in the forum searches it would be useful to include results from the wiki, so people can see the condensed version and simple questions could be avoided.


another aspect to this is code. having speciallized projects that people can start with and from there engineer it to their needs,  and post updates they made  and allow people who use the different examples to rate how useful they found it.

just some ideas that could help people get the most from and the wiki and streamline the discussions.  
2  Forum 2005-2010 (read only) / Development / Re: new arduino emulator - emulare on: September 24, 2010, 02:07:24 am
Total noob, tried installing emulare, it opens, but Iget an error message

Unhandled exception has occurred in your application if you click Continue , the application will ignore thia error and attempt to continue, if you click quit the application will close immediately

Could not laod file or assembly 'SimpleDiag. Version=1.0.3906.24145. Culture=neutral, PublicKey Token=Null' or one of it's dependencies. An attempt was made to load a program with an incorrect format.

Under details I get the following:

See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.BadImageFormatException: Could not load file or assembly 'SimpleDiag, Version=1.0.3906.24145, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format.
File name: 'SimpleDiag, Version=1.0.3906.24145, Culture=neutral, PublicKeyToken=null'
   at emulare.Interface.Diagram.InitializeComponent()
   at emulare.Interface.Diagram..ctor(BoardInfo board, MainWindow mainWindow)
   at emulare.Interface.MainWindow.NewBoardMenuItem_Click(Object sender, EventArgs e)
   at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)
   at System.Windows.Forms.ToolStripMenuItem.OnClick(EventArgs e)
   at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)
   at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)
   at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)
   at System.Windows.Forms.ToolStripDropDown.OnMouseUp(MouseEventArgs mea)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ToolStrip.WndProc(Message& m)
   at System.Windows.Forms.ToolStripDropDown.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].



************** Loaded Assemblies **************
mscorlib
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.4206 (VistaSP2GDR.050727-4200)
    CodeBase: file:///C:/Windows/Microsoft.NET/Framework64/v2.0.50727/mscorlib.dll
----------------------------------------
emulare
    Assembly Version: 1.7.0.0
    Win32 Version: 1.7.0.0
    CodeBase: file:///C:/Users/Carl/Desktop/Arduino/emulare/emulare_1.7/emulare_1.7/emulare.exe
----------------------------------------
emulare_core
    Assembly Version: 1.0.0.0
    Win32 Version: 1.0.0.0
    CodeBase: file:///C:/Users/Carl/Desktop/Arduino/emulare/emulare_1.7/emulare_1.7/emulare_core.DLL
----------------------------------------
System.Windows.Forms
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.4016 (NetFxQFE.050727-4000)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.4205 (VistaSP2GDR.050727-4200)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Drawing
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.4016 (NetFxQFE.050727-4000)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System.Configuration
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.4016 (NetFxQFE.050727-4000)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Configuration/2.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
System.Xml
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.4016 (NetFxQFE.050727-4000)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
WeifenLuo.WinFormsUI.Docking
    Assembly Version: 2.3.1.28514
    Win32 Version: 2.3.1.0
    CodeBase: file:///C:/Users/Carl/Desktop/Arduino/emulare/emulare_1.7/emulare_1.7/WeifenLuo.WinFormsUI.Docking.DLL
----------------------------------------

************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

For example:

<configuration>
    <system.windows.forms jitDebugging="true" />
</configuration>

When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.


not really sure what to do, I run vista which sucks

Thanks in Advance,

Carl :o
3  Forum 2005-2010 (read only) / Development / Re: Any interest in high-power LED driver shields? on: December 02, 2010, 03:26:53 pm
Quote
Might have to get a little creative to fit in six 0.2" spacing terminal blocks. Also I'm looking for a way to be able to stack these boards while being able to screw/unscrew the terminal blocks.

have you thought about molex connectors such as:

http://www.mouser.com/ProductDetail/Molex/39500-0007/?qs=sGAEpiMZZMsD

just a thought,

Carl
4  Forum 2005-2010 (read only) / Interfacing / Re: Thermocouple confusion on: December 10, 2010, 08:51:51 pm
thanks; brainfart
5  Forum 2005-2010 (read only) / Interfacing / Re: Thermocouple confusion on: December 10, 2010, 01:09:05 pm
thanks for clearing that up, as for the complete code, it's still very rough and incomplete. it will be reading the thermocouple and converting it to degrees F and displaying it on the LCD, but also will have an input function to program the rate of increase to set temperatures; via a keypad.

it will pretty much be a thermostat following a set pattern of steps of ramping at a certain rate of climb and holding for a certain amount of time at that temperature.

All the while it will display on the LCD the current temp and the temp it is ramping to. if things work out for that and I have extra room it's nice to be able to review the program, see how much longer it should take to reach the next temp or how much longer it is held at a certain temp. so far my code is very rough and I don't have much

I'm building it in steps, this is just a program to read the thermocouple and output to the lcd the temp

I get an error when I compile that constVolt cannot be used as a function, and also a bunch of references to java on lines that are not in the program



Code:
#include <math.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2);
#define thermocouplePIN0
const float constVolt = 5.0/1024.0; // Volts per analog digit
const float tempSlope = 355.2823; // slope of linear equation
const float tempOffset = -16.7664; // y int of linear equation
float volts = 0;
int temp = 0;


int thermocouplePin = 0;

void setup(){
  Serial.begin(9600);//hardware serial to PC
  lcd.begin(20,4); //sets up columns and rows
}

void loop()
{
 volts=constVolt(analogRead(thermocouplePin));           // read ADC and convert it to volts
 int temp=(tempSlope*volts)+tempOffset;                       // convert volts to temp in degrees F
 
 
lcd.print("Current Temp: "); //display temp
lcd.print(temp);
lcd.print(" degrees F");
delay (100);
}


this is the program for reading the keypad and displaying it on the LCD, it still needs tweaking on the hardware end, but it seems overall functional.


Code:
char keypressed = 0;
int keyboardPin = 0;    // Analog input pin that the keypad is attached to
int keyboardValue = 0;   // value read from the keyboard
int k = 0; //
int kbvalue = 0;//
int kbv = 0;
#include <LiquidCrystal.h>
LiquidCrystal lcd(12,11,5,4,3,2);

void setup(){
Serial.begin(9600);// hardware serial to PC
lcd.begin(16, 2); //sets up columns and rows
}

void loop()
{
  int sensorValue = analogRead(A0);
  Serial.println(sensorValue, DEC);
  delay(200);
  
  lcd.setCursor(0,1);
  keyboardValue = analogRead(keyboardPin);   // read the keyboard value (0 - 1023)
  while (keyboardValue < 25)
  {
    //do nothing until a key is pressed
    keyboardValue = analogRead(keyboardPin);
    delay(50);
  } //end of do nothing till a key is pressed
                                            
  int k = kbValue(keyboardValue);   // maps the value of the key being pressed "keypressed" i.e. 0-9
  
  Serial.println(k);  // print the value back to the Serial view window on your PC
  delay(1000);
}

// interpret the keyboard routine
int kbValue(int kbv)
{
  if (keyboardValue <=25)
 {
delay (30);}//debounces keypress; does nothing until a key is pressed
  else if ((keyboardValue >25) && (keyboardValue <=68)){keypressed = 1;}
  else if ((keyboardValue >68) && (keyboardValue <=108)){keypressed = 2;}
  else if ((keyboardValue >108) && (keyboardValue <=153)){keypressed = 3;}
  else if ((keyboardValue >153) && (keyboardValue <=179)){keypressed = 'enter';}// a key
  else if ((keyboardValue >179) && (keyboardValue <=225)){keypressed = 4;}
  else if ((keyboardValue >225) && (keyboardValue <=325)){keypressed = 5;}
  else if ((keyboardValue >325) && (keyboardValue <=415)){keypressed = 6;}
  else if ((keyboardValue >415) && (keyboardValue <=508)){keypressed = 'erase';} //b key
  else if ((keyboardValue >508) && (keyboardValue <=560)){keypressed = 7;}
  else if ((keyboardValue >560) && (keyboardValue <=680)){keypressed = 8;}
  else if ((keyboardValue >680) && (keyboardValue <=773)){keypressed = 9;}
  else if ((keyboardValue >773) && (keyboardValue <=834)){keypressed = 'menu';} // c key
  else if ((keyboardValue >834) && (keyboardValue <=898)){keypressed = '.';} // menu key
  else if ((keyboardValue >898) && (keyboardValue <=945)){keypressed = 0;}
  else if ((keyboardValue >945) && (keyboardValue <=970)){keypressed = '-';} //enter key
  else if (keyboardValue >970){keypressed = '+';} //d key

switch(keypressed){

case 0:
lcd.print(0);
delay(250);
// do 0
break;
  
case 1:
lcd.print(1);
delay(250);
// do 1
break;

case 2:
lcd.print(2);
delay(250);
// do 2
break;

case 3:
lcd.print(3);
delay(250);
// do 3
break;

case 4:
lcd.print(4);
delay(250);
//do 4
break;

case 5:
lcd.print(5);
delay(250);
// do 5
break;

case 6:
lcd.print(6);
delay(250);
// do 6
break;

case 7:
lcd.print(7);
delay(250);
// do 7
break;

case 8:
lcd.print(8);
delay(250);
// do 8
break;

case 9:
lcd.print(9);
delay(250);
// do 9
break;

case 'a':
lcd.print("a");
delay(250);
// do a
break;

case 'b':
lcd.print("b");
delay(250);
// do b
break;

case 'c':
lcd.print("c");
delay(250);
//do c
break;

case 'menu':
lcd.print("menu");
delay(250);
// do menu
break;

case 'enter':
lcd.print("enter");
delay(250);
// do enter
break;

case 'd':
lcd.print("d");
delay(250);
// do d
break;
}
 
while (keyboardValue >=25);          //wait until key no longer being pressed before continuing
  
return keypressed;
}


like I said it is very rough.


thanks for your patience,

Carl
6  Forum 2005-2010 (read only) / Interfacing / Re: Thermocouple confusion on: December 09, 2010, 08:21:00 pm
if I don't need precision beyond one degree, but need to use the finer detail for the slope and offset, would it be easiest to use the a multiple of the constants and then as the last function divide

Temp(F) = ((35528 * Volts) - 1676)/100

Versus

Temp(F) = (355.2823 * Volts) - 16.7674

does that still need to be floating point if I need 2 decimal places resolution on the input voltage?

thanks in advance,

Carl
7  Forum 2005-2010 (read only) / Interfacing / Re: Thermocouple confusion on: November 24, 2010, 10:34:41 am
Thanks everyone  for the input, it makes a lot of sense I think I've implemented What was suggested in the updated code below. one thing I need verified is if I used the #define function properly. especially the negative value for tempOffset


Quote
Including a header file in the source code and including a library in the compiler/linker output are two different things.

The compiler will see the header file, and compile the corresponding source file, to create an object file. The linker will then pick stuff it needs, and only what it needs from the object file.

I think I understand this, including a library in the program doesn't add any more to the compiled than the functions used in the program so It cant hurt to include it. but so far I haven't used it and don't foresee needing it so I haven't included it.

wayneft mentioned the map function, it does look like a potentially simplfied approach; but at this point I think it's good for me to do it long hand as I need to learn the basic syntax; perhaps in the future I'll change it over once I better understand it.


Gardner said:

Quote
This would address part of your question, and maybe give you an idea how to deal with the rest, without using any floating point or math.

is there an advantage to avoiding floating point? does it use more memory than the method you mention??

Thanks again for all the input, the next step for me will be implementing a 4x4 matrix keypad for input of the schedule of the firing. so you'll likely see a message on the board to that effect

As for the remarks in the code I posted below I think it would make sense to whoever was reading it.  

Another thing I' like to add to  is the lcd.print (temp)
If I want to add something like Current Temp : (temp) degrees F
would it be that simple

lcd.print Current Temp : (temp) degrees F

also if I want to use the degree symbol where do I access that character? do I need to use it's ASCII value? that's where things get muddy for me.


Thanks in advance,

Carl

Quote
/*

Analog input from T/C amp displayed as value on LCD

*Varied 0-5Vdc to analog input 0

*LCD RS pin to digital pin 12
*LCD Enable pin to digital pin 11
*LCD D4 to digital pin 5
*LCD D5 to digital pin 4
*LCD D6 to digital pin 3
*LCD D7 to digital pin 2
*LCD R/W pin to GND
*LCD V0 Pin to 0-5V for contrast

*/

// include library code
#include <LiquidCrystal.h>

// initialize with the numbers of interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

int sensorPin =A0; //select input pin for thermocouple amplifier
int sensorValue =0; //variable to store the value coming from the sensor
float temp =0; //variable to store calculated temp


#define const float constVolt 5.0/1024.0 //constant converting analog value 0-1023 to 0-5v; when multiplied by sensorValue becomes X in linear equation Y=mX+b
#define const float tempSlope 355.2823 //constant for slope(m) of linear equation  Y=mX+b
#define const float tempOffset -16.7664 //constant for y intercept(b) of linear equation Y=mX+b
//temp = tempSlope * constVolt * sensorValue + tempOffset

void setup() {
  //setup the LCD's number of columns and rows
  lcd.begin(20, 4);
}

void loop() {
  // read value from T/C:
 sensorValue = analogRead(sensorPin);
 // convert to degrees F
 temp = (tempSlope)*(constVolt)*(sensorValue)+(tempOffset)
  //set the cursor to column 0, line 1
 lcd.setCursor(0,1);
  // print temp value
 lcd.print(temp);
 



  

8  Forum 2005-2010 (read only) / Interfacing / Thermocouple confusion on: November 23, 2010, 06:15:08 am
I posted this to another thread from a while back, but since it may no longer be followed I'm posting it as a fresh thread

I'm going to be using the AD595 with a type K thermocouple for a kiln controller.

so far I'm just trying to get a value to show on an LCD that is the analog value converted to degrees F

the AD595 puts out a linear 0 - 5v for the input from the thermocouple. that said, I plan to use a pot for test purposes, the formula for converting the voltage to degrees F is as follows.

Temp(F) = (355.2823 * Volts) - 16.7674


now I need to convert the analog input from 0-1023 back to volts

so I'm figuring I'll be dividing 5  by 1024 giving me an awkward decimal for the constant

in other words I'll be multipyling the input value 0-1023  by 5/1024

multiplying that by 355.2823

and subtracting 16.7674

to render the temperature in degrees F

that's where it gets hazy for me

for one thing I don't see any reason to include the entire math library if I'm only going to be using a single function, and I'm not even sure that is in there. I see other examples where they do use math.h but memory is going to be precious in this application so I'm looking to keep it as lean as possible.

can I just define a constant as the fraction 5/1024

the following is what I have with some things I know to be incorrect such as how to define the constant and the math function converting the volts to the temperature value in degrees F

I also know I could simplify it by multiplying 5*355.2823  and dividing that by 1024 (giving me 1.7348 for the constant - constVolt in the example below) then I only need to multiply it by the sensorValue and subtract 16.7674

in other words (constVolt*sensorValue)-16.7674

with constVolt now defined as 1.7348

So here is what I have so far

thanks for any input and Advice,

Carl


Quote
/*

Analog input from T/C amp displayed as value on LCD

*Varied 0-5Vdc to analog input 0

*LCD RS pin to digital pin 12
*LCD Enable pin to digital pin 11
*LCD D4 to digital pin 5
*LCD D5 to digital pin 4
*LCD D6 to digital pin 3
*LCD D7 to digital pin 2
*LCD R/W pin to GND
*LCD V0 Pin to 0-5V for contrast

*/

// include library code
#include <LiquidCrystal.h>

// initialize with the numbers of interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

int sensorPin =A0; //select input pin for thermocouple amplifier
int sensorValue =0; //variable to store the value coming from the sensor
float temp =0; //variable to store calculated temp

#define constVolt 5/1024 //constant converting analog value 0-1023 to 0-5v

void setup() {
  //setup the LCD's number of columns and rows
  lcd.begin(20, 4);
}

void loop() {
  // read value from T/C:
 sensorValue = analogRead(sensorPin);
 // convert to degrees F
 temp = (constVolt)*(sensorValue)*(355.2823)-16.7674 
  //set the cursor to column 0, line 1
 lcd.setCursor(0,1);
  // print temp value
 lcd.print(temp);
 



  


9  Forum 2005-2010 (read only) / Interfacing / Re: Keypad interface on: December 06, 2010, 11:30:14 pm
It does click, I think what was happening was when I tested it originally I didn't have a hard back so when I pressed it it wasn't always clicking, it was pinching the back toward the dome if that makes any sense, when I placed it on a hard surface and tested it it was more uniform,

the lower values were a much tighter range with a pronouced dead band between the key values;

the last five overlap quite a bit which confuses me, it would make sense if the last four overlapped, the last row resistor would need to be adjusted;  I figured this all out in a spreadsheet, and granted the resistor values varied some from the color code, but that was a idealized example, that said, I still would expect the values to be more separated. I may need to tweak some values, I suppose it could just be the last row, the overlap on the "menu" button might be due to the "." button's overlap

 sometimes just writing this all down make things make more sense, I'll probably just put a trimpot in series with the last  row resistor to see If increasing that will make a big difference. but with overlap on all the last five it still confuses me; I'll try tweaking the 1.2 k value which confuses me as I went from 3x4, to 4x4  adding the 1.2k. if it were that one, I would have guessed it would throw off a column, not a row as it is.  

below is the layout of the keypad and the values I got on serial monitor, I pressed the button numerous times for varying duration and then took the highest and lowest values.  



             5v
              |
             1k
              |
                 1             2             3              enter
              |
            820
              |
                  4             5             6              erase
              |  
             1k
              |
                  7             8             9              menu
              |
            1.2K
              |
                  .              0             -              +
 
A0 -- 180 ----- 670 ------ 3.3K ------- 14.8K -------Gnd


1          39 - 51
2          80-91
3          117-136
enter    139-178
4          181-196
5          277-309
6          356 - 411
erase    424-503
7          510 - 531
8          599-674
9          745-773
menu    792-833
.           745-829
0          749-911
-           900-947
+          912- 968


A few other things I'm curious of- when is the value It reads evaluated  against  switch/case conditions; is it the first value it puts out, is there a way to delay it's reading by a few millisecond while it normalizes some; it seems the most extemely off  the values is the first and last values read in the serial monitor,

If I program in a dead band between the closer values, when I press a button and the value reads within that band and outside that band will it still read the value when it is outside the band

for example between 6 and erase and erase and 7 there is little slack, but every time I pressed the button it would always show values outside the area I plan to exclude  for example between erase and 7 there is only about 7 values,  if I widen that gap in my cases to 20 in case it decides to overlap in the next thousand times versus the 20 or so times I pressed it. the only time the values could be confused were the first and last values it showed on serial monitor.  but in all the button presses it always returns a value squarely within the ranges at least for the lower values (not the last five that need hardware tweaking not software)

I'll try these things but this is new to me.

another thing that puzzles me is when I tried attaching an lcd that would output the value as it was pushed; It only seems to display the value once.   and I need to reset it to get it to read the next key press
I'm missing some thing, but am not sure what.  any insight would be much appreciated

-carl

Code:
char keypressed = 0;
int keyboardPin = 0;    // Analog input pin that the keypad is attached to
int keyboardValue = 0;   // value read from the keyboard
int k = 0; //
int kbvalue = 0;//
int kbv = 0;
#include <LiquidCrystal.h>
LiquidCrystal lcd(12,11,5,4,3,2);

void setup(){
Serial.begin(9600);// hardware serial to PC
lcd.begin(16, 2); //sets up columns and rows
}

void loop()
{
  int sensorValue = analogRead(A0);
  Serial.println(sensorValue, DEC);
  delay(200);
  
  lcd.setCursor(0,1);
  keyboardValue = analogRead(keyboardPin);   // read the keyboard value (0 - 1023)
  while (keyboardValue < 25)
  {
    //do nothing until a key is pressed
    keyboardValue = analogRead(keyboardPin);
    delay(50);
  } //end of do nothing till a key is pressed
                                            
  int k = kbValue(keyboardValue);   // maps the value of the key being pressed "keypressed" i.e. 0-9
  
  Serial.println(k);  // print the value back to the Serial view window on your PC
  delay(1000);
}

// interpret the keyboard routine
int kbValue(int kbv)
{
  if (keyboardValue <=25)
 {
delay (30);}//debounces keypress; does nothing until a key is pressed
  else if ((keyboardValue >25) && (keyboardValue <=68)){keypressed = 1;}
  else if ((keyboardValue >68) && (keyboardValue <=108)){keypressed = 2;}
  else if ((keyboardValue >108) && (keyboardValue <=153)){keypressed = 3;}
  else if ((keyboardValue >153) && (keyboardValue <=179)){keypressed = 'enter';}// a key
  else if ((keyboardValue >179) && (keyboardValue <=225)){keypressed = 4;}
  else if ((keyboardValue >225) && (keyboardValue <=325)){keypressed = 5;}
  else if ((keyboardValue >325) && (keyboardValue <=415)){keypressed = 6;}
  else if ((keyboardValue >415) && (keyboardValue <=508)){keypressed = 'erase';} //b key
  else if ((keyboardValue >508) && (keyboardValue <=560)){keypressed = 7;}
  else if ((keyboardValue >560) && (keyboardValue <=680)){keypressed = 8;}
  else if ((keyboardValue >680) && (keyboardValue <=773)){keypressed = 9;}
  else if ((keyboardValue >773) && (keyboardValue <=834)){keypressed = 'menu';} // c key
  else if ((keyboardValue >834) && (keyboardValue <=898)){keypressed = '.';} // menu key
  else if ((keyboardValue >898) && (keyboardValue <=945)){keypressed = 0;}
  else if ((keyboardValue >945) && (keyboardValue <=970)){keypressed = '-';} //enter key
  else if (keyboardValue >970){keypressed = '+';} //d key

switch(keypressed){

case 0:
lcd.print(0);
delay(250);
// do 0
break;
  
case 1:
lcd.print(1);
delay(250);
// do 1
break;

case 2:
lcd.print(2);
delay(250);
// do 2
break;

case 3:
lcd.print(3);
delay(250);
// do 3
break;

case 4:
lcd.print(4);
delay(250);
//do 4
break;

case 5:
lcd.print(5);
delay(250);
// do 5
break;

case 6:
lcd.print(6);
delay(250);
// do 6
break;

case 7:
lcd.print(7);
delay(250);
// do 7
break;

case 8:
lcd.print(8);
delay(250);
// do 8
break;

case 9:
lcd.print(9);
delay(250);
// do 9
break;

case 'a':
lcd.print("a");
delay(250);
// do a
break;

case 'b':
lcd.print("b");
delay(250);
// do b
break;

case 'c':
lcd.print("c");
delay(250);
//do c
break;

case 'menu':
lcd.print("menu");
delay(250);
// do menu
break;

case 'enter':
lcd.print("enter");
delay(250);
// do enter
break;

case 'd':
lcd.print("d");
delay(250);
// do d
break;
}
 
while (keyboardValue >=25);          //wait until key no longer being pressed before continuing
  
return keypressed;
}

10  Forum 2005-2010 (read only) / Interfacing / Re: Keypad interface on: December 06, 2010, 10:18:12 am
Quote
This is a very legitimate scheme when you are using hard metal-to-metal contact switches.



as I understand it this is a metal to metal contact, http://www.satistronics.com/images/v/201002/12668583500.jpg

I think they are referred to as snap dome buttons,

the carbonized rubber buttons are the kind you see in tv remotes
11  Forum 2005-2010 (read only) / Interfacing / Re: Keypad interface on: December 06, 2010, 09:33:35 am
they're normally open, but when I press it and the value It evens out at is 500 for a certain key, as it is pressed it shows a few different values like 120 250 and leveling out at around 500 if it is pressed a little harder it may increase to 510 it's difficult to read as the values scroll by so fast on serial monitor, is there a way to sample the values less frequently? perhaps I'm overthinking this, but if it reads those lower values, isn't it going to recognize those first?

I feel stupid for asking these hypotheticals, I need to get it hooked up to some means of output, perhaps the LCD, I need to figure that out too. pretty much the hello world program with different string for each button

I'll keep at this until I get it, I get a little discouraged when things don't work perfectly the first time; generation X instant gratification disorder

thanks for not just ignoring me, and making me think about it further

-carl
12  Forum 2005-2010 (read only) / Interfacing / Re: Keypad interface on: December 06, 2010, 01:00:31 am
hooked it up and used the serial monitor; the values are all over the place, I haven't really set it up with any complex program, but with the values all over the place when pressing the buttons, it hardly seems worth it until I get a more uniform result. I'm using a membrane type keypad and it seems to vary in resistance depending on how firmly you press the button, I may need to go with the interface chip; that has built in debouncing, but uses four inputs. it can send it as serial signal, but that is a little beyond me at this point.

I may try devising code to only recognize values that it stays at the same value ( with a tolerance range +/- twenty or so)  for a certain amount of time, (say 50ms) then compare average value to the ranges I program in. I'm going to try the program as it stands but I'm pretty skeptical of the reliability, and expect false values on the increase or decrease. it will also give me practice on output as  well, probably just turn on a different LED for each key and hold it there for a half second. we'll see where it goes from here.
13  Forum 2005-2010 (read only) / Interfacing / Re: Keypad interface on: November 26, 2010, 03:14:41 pm
I figured it out, I had it wired wrong, now it gives a pretty linear value
for the fourth column I added a 1.2k

Now to see which resistor values I already have

thanks for the input,

Carl
14  Forum 2005-2010 (read only) / Interfacing / Re: Keypad interface on: November 26, 2010, 01:19:58 pm
I saw that tutorial, but I have a 4x4 matrix, which makes things 33% tighter. breaking 5v into 12 values seems easier than 16. I try to add another resistor for the fourth column and it gets confusing would I go smaller Analog -col1 - 1k - col2- 820 -col3- 640?- Col4 - 1k - ground
or larger analog -col1- 1.2K - col2 - 1k - col3 - 820 - col4 - 1k - ground

Still playing with the values

thanks for the input,

Carl
15  Forum 2005-2010 (read only) / Interfacing / Re: Keypad interface on: November 25, 2010, 09:47:16 am
You'd think that, but some values are closer than 2mv apart while the ones at the beginning are upwards of 30mv apart. If I figure in +-10% it causes overlap in the values where the low end tolerance of one value is higher than the previous value's low end tolerance. so there's the chance there would be ambiguity between the closer values or else there would be such a small range to look at 2mv that a slight change in value may throw it all out of whack and it not even looking in the right range for the corresponding key.

if you need to see my math, I have an open office document that allows you to see how I determined this.

thanks-

Carl
Pages: [1] 2 3 4