Show Posts
Pages: 1 ... 5 6 [7]
91  Forum 2005-2010 (read only) / Frequently-Asked Questions / Re: Memory overload? on: May 24, 2007, 10:23:30 am
The two easiest ways to clear an array are a loop with an assignment and the memset function

#include <string.h>

void * memset  (  void *  dest,  
  int  val,  
  size_t  len
 )  
 
   Fill memory with a constant byte.

The memset() function fills the first len bytes of the memory area pointed to by dest with the constant byte val.


Returns:
The memset() function returns a pointer to the memory area dest.  



There are a couple of things I would try.

Increase the size of your storage array by a couple of bytes without changing anything else.  If this solves or changes the symptoms than it is an excellent indicator that you have a memory overrun in your code.

Clear the contents of the array prior to reading a new tag

It might be worthwhile to pair down the functionality of your code to just the component that is having the problem--tag reading.  To try and diagnose the problem within a simpler framework.

It looks like you might be able to send message through the serial port to a display device (computer).  I would suggest sending prints of the associated variables before and after sections (one at a time) to verify that the code is doing what you expect.  For the array it might be helpful to print the entire array in hex rather than as a string.

If your serial port is tied up, I would use the software serial library to send the debug output.

92  Forum 2005-2010 (read only) / Frequently-Asked Questions / Re: Memory overload? on: May 23, 2007, 10:50:33 am
If I'm reading your email correctly your code is generating a memory overrun.  This is a very common problem with C/C++ and is usually caused by accessing an array outside of its defined bounds.  If you post your code it might help identify the specific problem.
93  Forum 2005-2010 (read only) / Frequently-Asked Questions / Re: led display controll on: May 16, 2007, 10:00:28 am
Here is a fairly straightforward conversion of the BS2 program.  I haven't had a chance to compile this so there might be a few syntax errors.

 
/*
 * HC4LED.BS2 converted from PBASIC 2.5 to Arduino Wiring/Processing by wandrson@yahoo.com
 * This program demonstrates the use of the HC4LED display module
 * HC4LED Pinout:
 *   Pin1 = +5VDC (White wire)
 *   Pin2 = Gnd
 *   Pin3 = Blank (Must connect to Gnd to enable display)
 *   Pin4 = No Connection
 *   Pin5 = Clock (Connect to pin 1 for this demo program)
 *   Pin6 = Data (Connect to pin 0 for this demo program)
 *
 *
 * To display values:
 *   Set the "zeros" variable to 0=No leading zeros; or 1=Show leading zeros
 *   Set the variable "value" to 0 to 9999
 *   Then use "GOSUB DisplayValue" to show the value on the display
 *
 * Each segment of the display is addressable, so you can create letters
 *  and symbols.
 * To display custom symbols:
 *  Set the variables "segments(0)" thru "segments(3)" (segments(0) is on the left)
 *   simply add the segment values that you want on
 *  Then use "GOSUB DisplaySegments" to show the segments on the display
 *
 *   ---4---
 *  |       |
 *  2       8
 *  |       |
 *  |---1---|
 *  |       |
 * 64       16
 *  |       |
 *   --32---
 *
 * For example "F" would be 4+2+1+64 = 71
 *
 */
 
int Clock=13;
int Dat = 11;
 
int vWord;                  // Holds value to display
byte cnt;                  // Used by display routines
byte segment[4];      // Used by display routines & customer chars
int digits[] = {126, 24, 109, 61, 27, 55, 119, 28, 127, 31 }; // define numbers 0-9
 
void setup()
{
     pinMode(Dat, OUTPUT);
     pinMode(Clock, OUTPUT);
}
 
/*
 * Call with:
 *  segments(0) thru segments(3) set to custom character values
 *  segments(0) is on the left; segments(3) is on the right
 */
void DisplaySegments()
{
     shiftOut(Dat, Clock, MSBFIRST, segment[3]);
     shiftOut(Dat, Clock, MSBFIRST, segment[2]);
     shiftOut(Dat, Clock, MSBFIRST, segment[1]);
     shiftOut(Dat, Clock, MSBFIRST, segment[0]);
     digitalWrite(Dat, (segment[0] & 1));
     digitalWrite(Clock, HIGH);
     // Clock MUST remain high for at LEAST 1 millisecond for the
     // new data to be latched onto the display.
     delay(1);
}
 
/*
 * Call with:
 *  parm = (value to display)
 */
void DisplayValue(int parm)
{
     int dig3;
     int dig2;
     int dig1;
     int dig0;
      
     if (parm < 10000) {
           dig3 = parm / 1000;
           dig2 = (parm - (dig3 * 1000))/100;
           dig1 = (parm - (dig3 * 1000) - (dig2 * 100))/10;
           dig0 = (parm - (dig3 * 1000) - (dig2 * 100) - (dig1 * 10));
           segment[0] = digits[dig0];
           segment[1] = digits[dig1];
           segment[2] = digits[dig2];
           segment[3] = digits[dig3];
     }
}
 
void loop()
{
     int value;
 
     while(1)                                                      // Repeat forever
     {
           for (value = 0; value <=1000; value++)      // Count from 0 to 1000
           {
                 DisplayValue(value);                        // Count from 0 to 1000
                 delay(1000);                                    // Display count on HC4LED module
           }
           delay(10000);                                          // Wait 1 second
           segment[0] = 28;                                    // Setup to display "72°F"
           segment[1] = 109;                                    // 2
           segment[2] = 15;                                    // °
           segment[3] = 71;                                    // F
           DisplaySegments();                                    // Display custom characters
           delay(20000);                                          // Wait 2 seconds
     }                                                                  // Repeat forever
}
94  Forum 2005-2010 (read only) / Frequently-Asked Questions / Re: max7219 with 8x8 matrix on: May 15, 2007, 01:38:30 pm
There should be 24 pins on the LED matrix.

The pinout for this device is:

PIN  FUNCTION
01   Col. 5 Green Cathode (-)
02   Col. 5 Orange Cathode (-)
03   Row. 5 Anode (+)
04   Col. 6 Green Cathode
05   Col. 6 Orange Cathode
06   Row 6 Anode
07   Col. 7 Green Cathode
08   Col. 7 Orange Cathode
09   Row 7 Anode
10   Col. 8 Green Cathode
11   Col. 8 Orange Cathode
12   Row 8 Anode
13   Row 4 Anode
14   Col. 4 Orange Cathode
15   Col. 4 Green Cathode
16   Row 3 Anode
17   Col. 3 Orange Cathode
18   Col. 3 Green Cathode
19   Row 2 Anode
20   Col. 2 Orange Cathode
21   Col. 2 Green Cathode
22   Row 1 Anode
23   Col. 1 Orange Cathode
24   Col. 1 Green Cathode

If I understand what you are trying to do you need to connect the Anodes (pins 3, 6, 9, 12, 13, 16, 19, & 22 -- NOT in this order go by Row #) to pins 14-17 and 20-23 of the MAX 7219.

Then choose either the orange or green cathodes (8 pins) and connect them to 2,3,5-8,10 & 11 of the MAX 7219

If you still have problems generate a manual netlist (pin to pin connection numbers between chips) and post that.  It would help identify your problem.
Pages: 1 ... 5 6 [7]