Well folks, I finally broke down and ordered the PCB's for FoxPup. I ordered them through dirtypcbs.com and could not be happier!!!!!! I got 10 boards and 3-9 day shipping from China for $40!!!If you think about it that's $4 a board.
I want to thank jetty for the Awesome sketch that he wrote for FoxCub!!! It worked like a charm on the first go. Great work jetty!!!
I also want to give a BIG thank you to victor_pv for the layout of the eagle file for FoxPup!!
I have a few changes that I would like to do to the PCB's before I make them public, that is if anyone is interested in them.
That looks awesome, nice work.
Regarding the dimming working without the zero cross active, the reason for this just happens to be a fluke, most of the time, you
are lined up somewhere on the A/C cycle, and the software internally clocks at 60Hz, but you don't get the resets to sync up to the cycle without the zero cross detect.
So it appears to work for the most part and dims, but if you look closely you'll see sometimes during the dimming it will blink out early or flicker at certain values
in the dimming cycle. It's more apparent if you set it to a slow dim. One of the test modes (all channels dimming from memory), illustrates this quite well, you'll see it flicker at the end
(typically lower values). And of course if you reset the 328p, you'll get a different point in the A/C cycle each time, either making it better (or worse).
Thanks for the explanation there jetty. It makes sense to me now. So far I have 3 of them built. I am working on, in another thread ( http://doityourselfchristmas.com/forums/showthread.php?37923-Renard-transmitter-from-a-Mega-2560 ) on getting the MEGA to transmit Renard data to the FoxPups when Vixen is not running. That way I can have random lights on between shows, and not just the channels connected to the MEGA.
Another way you could tackle that. You could do it in the 328p itself, there's already an activity timer in the interrupt:
if ( inactivityTimer > INACTIVITY_TIMEOUT )
You could set a variable in there that's a global declared volatile, and then in the main loop, if it's set, set the lights randomly, and then unset the variable the first serial byte that's received, that way you don't need the 2560.
Provided you don't add anything other than that to the interrupt, the change won't effect the speed of the interrupt.
jetty, your programming skills are light years ahead of me. I am still trying to figure out how you did what you did, much less modify the code, LOL. I will look at it this evening and see what I can come up with. Good thing that I have more than one Uno. That way in case I let the magical white smoke out of one I can always bring in a backup, rofl. Thanks for the info.
The MEGA sketch has that feature so you could copy it in an UNO sketch.
Here's a quick update for everyone on my progress with the FoxPups. I now have 3 FoxPups and the Mega working together peacefully, lol, for them anyway. I still haven't figured out the random mode yet though. I will be working on it. I actually picked up 5 for uno's for $4 each. Can always use more.
I figured out an added bonus to the FoxPups. If your USB to RS485 converter happens to go bad you can always switch one FoxPup into Master mode and connect it directly to the USB port and still run you show. This is what happened to me yeaterday. This video shows the Foxpups running with the second one from the right in Master Mode.
Cpwtech, I like what you have done with the whole "FoxPup" idea. Good job on your demo videos too. I'm especially interested in the conversion of the mega 2560. I would like to accomplish the same thing with my 2560 to make a controller out of it that takes in the renard protocol and has 32 channels. For my purposes they don't even have to be dimmable, just on/off. I thought about using the 48 generic serial idea for a 2560, but I would like to take advantage of the RS485 to locate it much farther away from the computer and just make it part of my planned RS485 network and other FoxCub16 boards.
What sketch did you end up using for the "renard in / 32 channels out"? Do you mind sharing?
Could it be just modifying the sketch to define channels as 32 and adding where all the port setup is to accommodate 16 more channels (matching the pin out to the mega2560 data sheet) and add port masks for the additional ports?
Anyway, great job, thanks for the awesome examples to follow.
Dpdigital wrote:Cpwtech, I like what you have done with the whole "FoxPup" idea. Good job on your demo videos too.What sketch did you end up using for the "renard in / 32 channels out"? Do you mind sharing?
Anyway, great job, thanks for the awesome examples to follow.
Thank you for the compliments. The sketch that I used for the 2560 was actually written by codec101, if memory serves correctly. I took his sketch and changed the channel assignments to match what I wanted.
int Ch[] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, 22, 23, 24, 25};
// an array of pin numbers to which channels are attached, first 15 are analog - PWM (2-13,44-46). The rest are digital only
int chanTotal = 32; // total number of channels
bool sync;
void setup()
{
for (int thisPin = 0; thisPin < chanTotal; thisPin++) //set pins for output
{
pinMode(Ch[thisPin], OUTPUT);
}
delay(10);
Serial.begin(115200);
delay(10);
sync = false;
}
void wait_for_serial()
{
while ( ! Serial.available() > 0 ) { }
}
int renardReadBytes( uint8_t *bytes, uint8_t bytes_size )
{
int in_byte = 0;
int bytes_read;
for ( bytes_read = 0; bytes_read < bytes_size; )
{
wait_for_serial();
in_byte = Serial.read();
switch (in_byte)
{
case(0x7E): // We saw the sync byte, start over!
sync = true;
return bytes_read;
case(0x7D): // Skip the pad byte
continue;
case(0x7F): // Escape character, we need to read one more byte to get our actual data
wait_for_serial();
in_byte = Serial.read();
switch (in_byte)
{
case(0x2F): // renard wants an 0x7D
in_byte = 0x7D;
case(0x30): // renard wants an 0x7E
in_byte = 0x7E;
case(0x31): // renard wants an 0x7F
in_byte = 0x7F;
}
}
bytes[bytes_read++] = in_byte;
}
return bytes_read;
}
int renardRead( uint8_t *bytes, uint8_t byte_count )
{
int in_byte = 0;
while ( ! sync )
{
wait_for_serial();
in_byte = Serial.read();
if ( in_byte == 0x7E ) // Sync byte signifies start of packet
sync = true;
}
if ( sync )
{
sync = false;
wait_for_serial();
in_byte = Serial.read();
if ( in_byte == 0x80 ) // Read from here
{
return renardReadBytes(bytes, byte_count);
}
}
return 0;
}
void loop()
{
uint8_t bytes[chanTotal], bytes_read;
bytes_read = renardRead(&bytes[0], chanTotal);
if ( bytes_read >= chanTotal )
{
// We have now received enough data for each channel, write them!
for (int currentCh = 0; currentCh < chanTotal; currentCh++) {
//first 12 channels are analog, PWM - dimming
if (currentCh < 12){
analogWrite(Ch[currentCh], (255 - bytes[currentCh]) );
// 255 - the value for the channel correctly sets channel value for the dirkcheap SSR. Otherwise on and off are reversed and bad things happen
}
else
{
//after channel 12, the rest are digital on - off only
if ((255 - bytes[currentCh]) < 255){
//if value is less than 255 then the channel is off
digitalWrite(Ch[currentCh], LOW);
}
else
{
//if value is 255 then the channel is on
digitalWrite(Ch[currentCh], HIGH);
}
}
}
}
}
The way I have the channel assignments are that the first 12 channels are dimmable and the rest are On/Off. It all seems to work pretty good, but then again I haven't built enough SSR's, D/C and A/C, to fully test it. Hope this helps you in your setup!
Thanks for posting the code. That looks like just the ticket to get me going. I will dig into the modifications for the channels I need for the shield I'm building.
