Show Posts
Pages: [1] 2 3 ... 7
1  Using Arduino / Programming Questions / Re: Change sub array data in one? on: June 15, 2013, 08:15:24 am
@nicoverduin:
Thank you for that pointer, pointer. That is worth playing with at the least for learning more.
2  Using Arduino / Programming Questions / Re: Change sub array data in one? on: June 14, 2013, 01:15:18 pm
Thank you UKHeliBob, problem solved. Why didn't I think of that? Don't answer.
3  Using Arduino / Programming Questions / Re: Change sub array data in one? on: June 14, 2013, 12:23:34 pm
@UKHeliBob: You are absolutely right about outside the ISR.
The ISR sends the data and manipulates. My difficulty was that I could not solve how to calculate once only per interrupt. I cannot place the manipulation code in loop() because it repeats. If I call a routine from the ISR the code might as well be in the ISR. How do I trigger the calculations to take place and where?
If you can tell me how to do that it will mean I asked the wrong question for the wrong reason, and the problem will be solved.
4  Using Arduino / Programming Questions / Re: Change sub array data in one? on: June 14, 2013, 12:09:30 pm
@UKHeliBob: Time. I thought it looked like it would be fast (if it had worked). This is in an interrupt routine.
@HazardsMind: Same as above, I dislike loops if I can avoid their overhead.
@pYro_65: I still see that loop in there despite the final elegant and short line.
Perhaps I should declare, destroy and re=declare the array as your suggested struct U64.
I already have several loops manipulating data before the next 14mS interrupt.
Thank you all for letting me know my attempt won't work.

ps @PeterH: That sounds good but a bit beyond my reach. To me pointers are a phobia like spiders.
5  Using Arduino / Programming Questions / Change sub array data in one? on: June 14, 2013, 09:39:46 am
I have an array...
byte Test[4][8]={{2,4,16,32,63,65,127,64},{2,4,16,32,63,65,127,64},{1,3,7,15,31,63,127,255},{0,0,0,0,0,0,0,0}};
and later wish to change one sub array...
Test[1] = {27,3,19,31,53,5,12,60};
does not work and gives 'expected primary expression before { token.
Will somebody please suggest the correct syntax other than addressing each element in turn and changing data.
Thanks
6  Using Arduino / LEDs and Multiplexing / 4off 8x8 dual colour matrix problem on: June 01, 2013, 06:29:57 am
I have been experimenting with expansion of the Bro Hogan circuit and the LedControl library.
I built 4 identical circuits and tested each individually as working correctly.
I then connected the four in a square and commonly connected the Vcc, Gnd, Clk and Load then daisy chained the Din and Dout, the last going into space. The code for LedControl was set to 8 devices (which introduced flicker)
At first glance all appeared to be OK but I had used symmetrical data.
I decided to leave all connected but set the number of devices to 2 (for one grid) and removed all references to the switching etc. of the other three)
A test to light a single led on the first display showed it on all 4 grids. To me this indicated that the addressing of a grid was allowing the data to be sent down the daisy chain regardless of how many devices or the address.
The attached interrupt is an external timer that interrupts and sends the data every one second.

I am baffled twice, once for the data addressing but second because the remaining 6 devices are still 'apparently' being switched into/out of shutdown!!!
Can anyone suggest a reason or where my fault is please.

Code:
/* RG Matrix Example   v.2 8/1/08  BroHogan
 * Demos 2 color 8x8 matrix driven by 2 MAX7821's
 */

#include "LedControl.h"                 // to drive the matrix
//#include "Binary.h"
#define ISR_FREQ 190     //190=650Hz    // Sets the speed of the ISR - LOWER IS FASTER
                 
// prescaler is /128 -  125,000/ISR_FREQ+1 (i.e 249=500Hz, 190=650Hz)

 
#define RED 0
#define GREEN 1
#define REDa 0                           // The address of the MAX7221 for the red leds                           // The address of the MAX7221 for the red leds
#define GREENa 1                         // The address of the MAX7221 for the green leds
#define REDb 2                           
#define GREENb 3                         
#define REDc 4                           // The address of the MAX7221 for the red leds
#define GREENc 5
#define REDd 6                           // The address of the MAX7221 for the red leds
#define GREENd 7                         // The address of the MAX7221 for the green leds

int maxInShutdown=RED;                // tells which MAX7221 is currently off
unsigned long ISRTime;                   // DEBUG to test how long in ISR

LedControl lc=LedControl(12,11,10,2); // pins 12=DataIn, 11=CLK, 10=LOAD + 4 MAX7221s
//LedControl lcb=LedControl(13,11,10,2);


volatile int count=0;

void setup() {
  lc.setIntensity(REDa,12);
//  lc.setIntensity(REDb,12);
//  lc.setIntensity(REDc,12);
//  lc.setIntensity(REDd,12);
  lc.setIntensity(GREENa,15);            // 0 = dim, 15 = full brightness 15
//  lc.setIntensity(GREENb,15);
//  lc.setIntensity(GREENc,15);
//  lc.setIntensity(GREENd,15);
  setISRtimer();                        // setup the timer
  startISR();                           // start the timer to toggle shutdown
  pinMode(2, INPUT);
  attachInterrupt(0, onTick, RISING);
  //Test to use only green
    lc.shutdown(REDa,true);
//    lc.shutdown(REDb,true);
//    lc.shutdown(REDc,true);
//    lc.shutdown(REDd,true);
    lc.shutdown(GREENa,false);
//    lc.shutdown(GREENb,false);
//    lc.shutdown(GREENc,false);
//    lc.shutdown(GREENd,false);
//  Serial.begin(9600);
}
void loop() {}


/////////////Below here should not need changing, could break it////////////
////////////////////////////////////////////////////////////////////////////
/////////////////////////////ISR Timer Functions ///////////////////////////
ISR(TIMER2_COMPA_vect) {  //This ISR toggles shutdown between the 2MAX7221's
// digitalWrite(2, maxInShutdown == RED ? HIGH : LOW);
  if(maxInShutdown==RED){
    lc.shutdown(GREENa,true);  // The order here is critical - Shutdown first!
//    lc.shutdown(GREENb,true);  // The order here is critical - Shutdown first!
//    lc.shutdown(GREENc,true);  // The order here is critical - Shutdown first!
//    lc.shutdown(GREENd,true);  // The order here is critical - Shutdown first!
    lc.shutdown(REDa,false);   // . . . Then restart the other.
//    lc.shutdown(REDb,false);   // . . . Then restart the other.
//    lc.shutdown(REDc,false);   // . . . Then restart the other.
//    lc.shutdown(REDd,false);   // . . . Then restart the other.
    maxInShutdown=GREEN;
//    Serial.println("Green off");
 }
  else {
    lc.shutdown(REDa,true);
//    lc.shutdown(REDb,true);
//    lc.shutdown(REDc,true);
//    lc.shutdown(REDd,true);
    lc.shutdown(GREENa,false);
//    lc.shutdown(GREENb,false);
//    lc.shutdown(GREENc,false);
//    lc.shutdown(GREENd,false);
    maxInShutdown=RED;
//    Serial.println("Red off");
  }

 
void onTick()
{
  SetLed(GREENa,count&7,6,true);
  SetLed(GREENa,(count-1)&7,6,false);
//  Serial.println(count);
  count=count+1;
}
void setISRtimer(){  // setup ISR timer controling toggleing
  TCCR2A = 0x02;                        // WGM22=0 + WGM21=1 + WGM20=0 = Mode2 (CTC)
  TCCR2B = 0x05;                // CS22=1 + CS21=0 + CS20=1 = /128 prescaler (125kHz)
  TCNT2 = 0;                            // clear counter
  OCR2A = ISR_FREQ;                     // set TOP (divisor) - see #define
}
 
void startISR(){  // Starts the ISR
  TCNT2 = 0;                            // clear counter (needed here also)
  TIMSK2|=(1<<OCIE2A);                  // set interrupts=enabled (calls ISR(TIMER2_COMPA_vect)
}
 
void stopISR(){    // Stops the ISR
  TIMSK2&=~(1<<OCIE2A);                  // disable interrupts
}
 
/////////   Wrappers for LedControl functions . . . //////////

void SetLed(byte Color, byte Row,byte Col, byte State){
  stopISR();            // disable interrupts - stop toggling shutdown when updating
  lc.setLed(Color,Row,Col,State);
//    Serial.println((Row+0));
  startISR();           // enable interrupts again
}
 
void SetRow(byte Color, byte Row, byte State){
  stopISR();            // disable interrupts - stop toggling shutdown when updating
  lc.setRow(Color,Row,State);
  startISR();           // enable interrupts again
}
 
void SetColumn(byte Color, byte Col, byte State){
  stopISR();            // disable interrupts - stop toggling shutdown when updating
  lc.setColumn(Color,Col,State);
  startISR();           // enable interrupts again
}
 
void ClearMatrix(){
  stopISR();            // disable interrupts - stop toggling shutdown when updating
  lc.clearDisplay(REDa);
  lc.clearDisplay(GREENa);
//  lc.clearDisplay(REDb);
//  lc.clearDisplay(GREENb);
//  lc.clearDisplay(REDc);
//  lc.clearDisplay(GREENc);
//  lc.clearDisplay(REDd);
//  lc.clearDisplay(GREENd);
  startISR();           // enable interrupts again
}
7  Forum 2005-2010 (read only) / Forum / Re: My Posts on: October 28, 2010, 08:21:08 am
Well that is really helpful and I thank you.
I just tried it on you, and it worked fine.
8  Forum 2005-2010 (read only) / Forum / My Posts on: October 26, 2010, 01:45:49 pm
I have not been able to find one, please help me if there is one, but a link to bring together all posts by one member (usually yourself) to make it easier than trying to remember where one posted and what.
Thanks
9  Forum 2005-2010 (read only) / Troubleshooting / Re: Practical Arduino logic analyser can't get going on: October 23, 2010, 03:38:04 pm
A final thank you for your valuable help.
10  Forum 2005-2010 (read only) / Troubleshooting / Re: Practical Arduino logic analyser can't get going on: October 23, 2010, 03:01:22 pm
First, should I have something in this List and if so what and how? If not then fine...
Commented the line you suggested and then stopped on...
Port.Clear()
  port.bufferUntil(LINE_FEED);

Then success.
I guess that when I connect all will be well once I reinstate the lines commented.
Will it pick up the Port from List when I plug Arduino in or do I manually enter it in some way.

Then... Thank you very much indeed.

[EDIT] and I have now managed the channels and the screen height to match my Netbook small screen. Thanks again.
11  Forum 2005-2010 (read only) / Troubleshooting / Re: Practical Arduino logic analyser can't get going on: October 23, 2010, 02:50:04 pm
I am afraid that the version I have used is the original unchanged SimpleSerialArduinoscope.pde.

It still contains the line that I changed in the file I modified a week or so ago to 4...
Oscilloscope[] scopes = new Oscilloscope[6];

The line highlighted by the error is...
  port = new Serial(this, Serial.list()[0], 115200);

In the message window there is a massive list of quesstions comments and answers, which I cannot copy and is too large to type, but it looks like something that might come up to help in the light of errors.

Most 'seems' irrelevant but the last piece does not...
ArrayOutOfBounds Exception: 0 at SimpleSerialArduinoscope.setup(SimpleSerialArduinoscope.java:110) at processing core.PApplet.handledraw(unknown source) That last section is repeated but with run instead of handledraw at Java.Lang.Thread.run(Thread.Java:619)
Needless to say it means nothing to me.
12  Forum 2005-2010 (read only) / Troubleshooting / Re: Practical Arduino logic analyser can't get going on: October 23, 2010, 01:37:38 pm
Thank you PaulS for your assistance. The app does run and open a window and then I receive an 'arrayOutOfBoundsException:0' and assume that the error is due to some parameters i will need to set regarding port etc.??

I am not in a position to connect Arduino today and assume that it will work when I do.

I am extremely grateful for your time and trouble.
13  Forum 2005-2010 (read only) / Troubleshooting / Re: Practical Arduino logic analyser can't get going on: October 23, 2010, 01:28:30 pm
Scarp the last result. I did not close the window of the IDE and restart it. I loaded from the menu into the old window and got the error.
Restarting cured that and I am now moving to the final error message which you predicted.
I needed to get this on post before you wasted time. I will now test the rest.
14  Forum 2005-2010 (read only) / Troubleshooting / Re: Practical Arduino logic analyser can't get going on: October 23, 2010, 01:17:32 pm
I thank you for continued support.

As stated I did produce the folders up to your quote except that what I actually did was to rename 'processing-arduino' to arduino and place it wholesale under libraries.
Quote
Then, you need to create a folder, in the libraries folder, named exactly "arduinoscope", not whatever you like.

Then, start the Processing IDE, and...

The only other difference is that I picked up the example file SimpleSerialArduinoscope.pde and dropped it on the Processing IDE and opened.
On this occasion I followed your instructions by going through the menu and path. Upon running I still got the same error.

To save questions; in libraries I have Arduinoscope\ then src & reference & library & examples.
In examples\ I have 3 examples one of which is SimpleSerialArduinoscope folder containing a data folder and java.policy.applet and SimpleSerialArduinoscope.pde

I obviously reserve the rest of your guidance for after this step is resolved.
15  Forum 2005-2010 (read only) / Troubleshooting / Re: Practical Arduino logic analyser can't get going on: October 23, 2010, 10:25:39 am
What is a pronoun...
A pronoun can replace a noun or another pronoun. You use pronouns like "he," "which," "none," and "you" to make your sentences less cumbersome and less repetitive.

In this case 'it' which I feel sure was actually decipherable in that the first two referred to the same thing, the IDE compiler, not much else was involved to give error messages! The third followed Arduinoscope which is an object  and so that is what it referred to.
I know you really are a teacher in disguise smiley
The presumptions that 'you' make are that I am naturally English speaking and that I am not a person with learning difficulties.

However, I stand corrected!!! I apologise for my hurried and poor grammar and hope that you are not offended by my response. I also know that I should not have put exclamation marks in the body of this sentence.

Here goes...
The Processing IDE issued a error message when I attempted to compile 'simpleserialarduinoscope.pde'. The message indicated that The package "Arduinoscope" did not exist and that I might be missing a library. I was then told by the Processing IDE where to place the library when and if I found the library.
The reason that I was running Arduinoscope in the IDE and not running the executable provided was because I had made changes to parameters within the source file.

I suspect (presume) that all the files and folders provided in the downloads that I mentioned in an earlier post in response to an earlier admonition, are not required and that in itself has caused some of my confusion.
I have been unable to find a comment (which I must have missed) in the book
http://books.google.co.uk/books?id=iwzo1-zmVXEC&pg=PA187&lpg=PA187&dq=arduino+logic+analyzer&source=bl&ots=mMlnyTl281&sig=LyUkxfC-1TcNkFFq9z8Q-9sSNIw&hl=en&ei=59rCTILgO93NjAfK2fi4BQ&sa=X&oi=book_result&ct=result&resnum=2&ved=0CBoQ6AEwATgU#v=onepage&q=arduino%20logic%20analyzer&f=false
 that I have read twice, that explains where the files go. I suspect that the folder network provided is not in a usable form exactly as the folder nest is provided. Some items appear to require moving and I am asking for somebody to kindly help me work out precisely which items go where in the system that I have got set up which is...
A Arduino Folder above Sketchbook above libraries and a Processing folder above Sketchbook above libraries.
When I know the answer that I seek, I feel sure that it will serve me well in future endeavours of this nature.

It is also very easy for those to whom this particular aspect is second nature, to forget that their is a first nature.

Quote
You need to start Processing, load a sketch, then run that sketch.
I did and received the error message to which I referred a few moments ago. Though I think I know, you didn't say which Sketch.
Pages: [1] 2 3 ... 7