hey gang--
I have a problem I am trying to work through..
I dont believe it to be 'code' related..(but who knows... maybe its an initialization error on my end?) and am looking for some general discussion on my problem.
- ** I am using the Led Control library from the PlayGround/GitHub for the MAX demos/examples
The project is made up of several PCB's....
1 x main board (Arduino brain + Waveshield built-in)
1 x 3-digit/7-segment display (MAX chip #1)
1 x 30-smd led bargraph (wired matrix style) (MAX chip #2)
1 x constant current board for the high current RGB LED star.
*each board with a MAX chip has its own voltage regulator..etc set-up on the pcb.. (FYI)


*the 3rd board with microSD socket is the 'main' board.. a custom Arduino/Waveshield hybrid
and a quick mock-up of it:
everything was/is working just fine.... like in the video, however I have some of events being triggered by some temporary momentary switches hanging off the side of the prop/blaster..
the end goal was to have the RELOAD button (current using a temp switch and manually reload) be connected to part of a DB9 (serial) connector and be secured int he magazine end.. and triggered when the magazine is pulled/re-inserted..etc..
the 30 x smd led bargraph has a MAX chip on it as well
So I have the wiring like so:
'6' total wires going into the DB-9 (serial) connector on the gun/blaster side:
V+
GND
DOUT (from MAX CHIP #1)
CS
CLK
RELOAD PIN (D2 on Arduino)
and '5' total wires going into the DB9 (serial) connector on the bargraph (magazine) side...
V+
GND
DIN
CS
CLK
on the magazine DB-9 (serial) connector... I took the open (matching) pin that the RELOAD (D2) is connected to (on the other DB-9 connector end).. and bridged it to GND.. (so on magazine side of DB-9 9 (female) I have the GND pin bridged to where the RELOAD pin (D2) will be coming in once the connectors are plugged together)...
- more or less making the DB-9 (serial) connector and using one of the pins as a momentary switch (magazine is inserted/serial connectors are mated up/'psuedo momentary switch is being held down'...............................magazine is pulled/serial connectors are disconnected/'psuedo momentary switch is "released"'.)
(and in my code.. if switch is LOW.. I can fire (magazine inserted).. ...
if HIGH.. cant fire.. (magazine is not inserted)
again.. this ALL WORKS FINE when using a momentary switch to reload (and the magazine is NOT being pulled/re-inserted)
with me so far? ![]()
the problem is now that I have removed the manually reload switch and moved it to the DB-9 (serial) connector as being part of the magazine....
1.) the max chip gets pulled (with the magazine) so it looses power..
2.) the max chips gets powered up again (when the magazine is inserted)..
during this process.. things 'broke'.
when I re-insert the magazine.. the audio plays..
but the bargraph does NOT 'update' (either reload the bargraph to full 30.. or display the current ammo count (variable) that is there when pulled/re-inserted.)
I first thought.. yikes!.. I need to initialize the chip all over again..(so I do..initialize, set intensity, clear...then call my update function)
then I thought maybe I needed to pause/delay a bit..to give the chip time to power on... which I did.. 100, 300, 1000.. didnt work.
- I'm at the point that if I re-insert now..
only PART of the bargraph updates? (or sometimes none at all?)
so I guess just general question/discussion.. suggestions on things to try?
how would YOU approach this? ![]()
after some playing around.. it 'seems' that when I powered back on.. it ONLY wants to update the FIRST group of LEDS in the bargraph..??
everytime I pull & re-insert the magazine..
Here are the two functions I call when the magazine is inserted 9depending on if amo was empty when pulled.. or ammo still had some left when magazine was pulled)..
if empty.. i go back to full count (bargraph = 30)
if not empty when magazine was pulled/re-inserted.. I just update the display to have the same remaining leds lit as it did before (whatever the bargraphCounter says.. i use it as a look up in my array and apply the binary values)
void reloadMagazine(){
Serial.println(F("MAGAZINE RELOADED"));
bargraphCount = 30;
/* re-initialize the second MAX chip (after being re-connected)*/
for(int group=4;group>=0;group--) {
for(int led=8;led>=0;led--) {
delay(5);
lc.setLed(1,group,led,true);
}
}
}
void magazineUpdate(){
Serial.println(F("MAGAZINE UPDATE.............."));
Serial.println(bargraphCount);
/* re-initialize the second MAX chip (after being re-connected)*/
//lc.shutdown(1,false); //initialize routine is done when magazine inserted now..before the function calls
//lc.setIntensity(1,15);
//lc.clearDisplay(1);
//delay(loadDelay); <-- yuk!
if(bargraphCount > 0){
for(int i=0; i < 4; i++){
Serial.println(pgm_read_byte_near(counterArray[30 - bargraphCount] + i), BIN); //<-- seems to print out fine? but not applied correctly?
lc.setRow(1,i,(pgm_read_byte_near(counterArray[30 - bargraphCount] + i)));
}
playcomplete("magin.WAV");
}
else if(bargraphCount == 0){
isReloaded = true;
playcomplete("reload.WAV");
reloadMagazine();
Serial.print(F("ZERO COUNTER MAGAZINE INSERT: "));
Serial.println(bargraphCount);
}
}
so why does it work when using momentary switch (RELOAD pin (D2) on Arduino?).. but not when connected to the DB-9 (serial) connector? (due to powering down/up the MAX chip? having to do with initializing the chip again?
*why does only the FIRST group of 8 leds update when things are powered back up/initialized/magazine inserted?
SEGS DP-G & DIG0 only?
I fire '3' shots...
and I look at the BINARY output from the ARRAY IN PROGMEM that I should be applying to the MAX chip.. and it looks fine.
11111
11111111
11111111
11111100
I keep coming back to this being a power down/up and initializing problem... (sometimes when insert magazine (connect DB-9 connector).. the main 3-digit display gets funky? (happened like 2-3 times now maybe I bumped something)..
otherwise the bargraph updates.. (correctly) but ONLY turned on the first set of 8 leds..and not the rest of the bargraph..??
tired now..
thanks! ![]()
update:
after trying and trying... and writing out variables..and making sure my loops my running.... it must be something with re-initializing the chip again (in the daisy chain of MAX chips)
since this chip is the 'second' (of only 20 max chips.. and runs off the DOUT of the first max chip..
how can or should I re-initialize it once it gets 're-connected' to the circuit?
the delay doesnt seem to be a factor...as it turns in quick/instantly.. and 'updates'.. but only the first set of 8 (still)
whenever the magazine is re-inserted.. this is how I re-initialize the chip again:
lc.shutdown(1,false);
lc.setIntensity(1,15);
lc.clearDisplay(1);
=magazineUpdate();
//or
lc.shutdown(1,false);
lc.setIntensity(1,15);
lc.clearDisplay(1);
reloadMagazine();
but it only 'partially' seems to update?
so maybe Im doing that/something wrong in that aspect??
thanks (again) ![]()