EFX-TEK

TEK Talk => I/O Support => FC-4 => Topic started by: robomaster-1 on November 03, 2015, 10:12:10 AM

Title: Controlling the FC-4+ with an Arduino
Post by: robomaster-1 on November 03, 2015, 10:12:10 AM
Can the  FC-4+ be controlled with and Arduino Board. I like the features of the FC-4+ and want to us it with and  Arduino Board.
Can this be done?
Title: Re: Controlling the FC-4+ with an Arduino
Post by: livinlowe on November 03, 2015, 11:28:11 AM
It sure can. Did you look at the docs for the FC-4? It lists the commands that control it. Just send those commands over a serial line!
Title: Re: Controlling the FC-4+ with an Arduino
Post by: JonnyMac on November 03, 2015, 05:39:28 PM
Assuming you have SoftSerial library installed, you might write functions that look like these:

UNTESTED!

void fc4_reset(byte addr)
{
  SoftSerial.write("!FC4");
  SoftSerial.write(addr);
  SoftSerial.write("X");
}


void fc4_level(byte addr, byte ch, byte level)
{
  SoftSerial.write("!FC4");
  SoftSerial.write(addr);
  SoftSerial.write("L");
  SoftSerial.write(ch);
  SoftSerial.write(level);
}


void fc4_digital(byte addr, byte ch, byte state)
{
  SoftSerial.write("!FC4");
  SoftSerial.write(addr);
  SoftSerial.write("D");
  SoftSerial.write(ch);
  SoftSerial.write(state);
}


void fc4_fade(byte addr, byte ch, byte levela, byte levelb, int fadems)
{
  SoftSerial.write("!FC4");
  SoftSerial.write(addr);
  SoftSerial.write("FH");
  SoftSerial.write(ch);
  SoftSerial.write(levela);
  SoftSerial.write(levelb);
  SoftSerial.write(fadems & 0xFF);
  SoftSerial.write(fadems >> 8);
}
Title: Re: Controlling the FC-4+ with an Arduino
Post by: robomaster-1 on December 04, 2015, 10:52:51 AM
Jon,

I thought you said that you did a project where wrote some code for a client if you did can I see what you did?
Title: Re: Controlling the FC-4+ with an Arduino
Post by: JonnyMac on December 04, 2015, 07:15:08 PM
I've written code for a friend that I cannot share. What I've written that can be shared is here -- right above your request. That's based on this:

http://www.efx-tek.com/php/smf/index.php?topic=2106

Here's another bit of code I found using Google

/*
* RC-4 Demo
* Jon Williams, EFX-TEK
* jwilliams@efx-tek.com
*
* Interface for EFX-TEK RC-4 SSR Output Board
* -- http://www.efx-tek.com/topics/rc-4.html
*/

void setup()
{
  Serial.begin(38400);                          // install RC-4 B/R jumper 
 
  for (int idx = 0; idx < 4; idx++) {
    setRC4(idx, 0);
  }
}

void loop()
{
  int idx, zigzag;
 
  for (idx = 0; idx <= 15; idx++) {             // counter demo
    setRC4(0, idx);
    delay(100);
  } 
  setRC4(0, 0);
   
  for (zigzag = 1; zigzag < 6; zigzag++) {      // zig
    for (idx = 1; idx <= 8; idx *= 2) {
      setRC4(1, idx);
      delay(50);
    }
    for (idx = 8; idx >= 1; idx /= 2) {         // zag
      setRC4(1, idx);
      delay(50);
    }
  }
  setRC4(1, 0);
}

void setRC4(int addr, int relays)
{
  Serial.print("!RC4");
  Serial.print(addr, BYTE);
  Serial.print("S");
  Serial.print(relays, BYTE); 
}
Title: Re: Controlling the FC-4+ with an Arduino
Post by: robomaster-1 on January 01, 2016, 02:41:34 PM
Since I have an RC-4 board I thought I would try out the RC-4 Demo code to see how it works. I compiled the program and got an error BYTE is no longer supported. Here the line that gave the error. Any thoughts. I would like to this working first before work on the FC-4+ code.

Serial.print(addr, BYTE);   
Title: Re: Controlling the FC-4+ with an Arduino
Post by: JonnyMac on January 02, 2016, 08:33:06 AM
Well, I guess that vaunted Arduino community support really isn't what it's cracked up to be.... :)

Please remember that we're not Arduino programmers, so anything we suggest vis-a-vis the Arduino is at your own risk.

Even if community support is lacking, the Arduino has pretty good reference pages (use Help\Reference). I used this one to modify the demo code
-- https://www.arduino.cc/en/Reference/Serial

Here is the updated demo -- it compiles, but I have not run it.

/*
* RC-4 Demo
* Jon Williams, EFX-TEK
* jwilliams@efx-tek.com
* Modified: 02 JAN 2016
*
* Interface for EFX-TEK RC-4 SSR Output Board
* -- http://www.efx-tek.com/topics/rc-4.html
*/

void setup()
{
  Serial.begin(38400);                                      // install RC-4 B/R jumper

  for (int addr = B00; addr <= B11; addr++) {               // reset all RC-4s
    setRC4(addr, B0000);
    delay(25);
  }
}

void loop()
{
  int bits, zigzag;

  for (bits = B0000; bits <= B1111; bits++) {               // counter demo
    setRC4(B00, bits);
    delay(100);
  }
  setRC4(B00, B0000);                                       // clear RC-4
  delay(100);

  for (zigzag = 1; zigzag < 6; zigzag++) {                  // run 5x
    for (bits = B0001; bits <= B1000; bits <<= 1) {         // zig
      setRC4(B00, bits);
      delay(50);
    }
    for (bits = B1000; bits >= B0001; bits >>= 1) {         // zag
      setRC4(B00, bits);
      delay(50);
    }
  }
  setRC4(B000, B0000);
  delay(50);
}

void setRC4(int addr, int relays)
{
  Serial.write("!RC4", 4);
  Serial.write(addr);
  Serial.write("S");
  Serial.write(relays);
}
Title: Re: Controlling the FC-4+ with an Arduino
Post by: robomaster-1 on January 13, 2016, 10:57:20 AM
Here is the code I am working with and the board is not responding I am not sure what is wrong?


/*
* RC-4 Demo
* Jon Williams, EFX-TEK
* jwilliams@efx-tek.com
* Modified: 02 JAN 2016
*
* Interface for EFX-TEK RC-4 SSR Output Board
* -- http://www.efx-tek.com/topics/rc-4.html
*/
#include <SoftwareSerial.h>

#define RX2   2
#define TX2   3

#define ON    1
#define OFF   0

#define ALL  0xFF                       // global address

SoftwareSerial SoftSerial(RX2, TX2);



void setup()
{
  Serial.begin(38400);                                      // install RC-4 B/R jumper

  for (int addr = B00; addr <= B11; addr++) {               // reset all RC-4s
    setRC4(addr, B0000);
    delay(25);
  }
}

void loop()
{
  int bits, zigzag;

  for (bits = B0000; bits <= B1111; bits++) {               // counter demo
    setRC4(B00, bits);
    delay(100);
  }
  setRC4(B00, B0000);                                       // clear RC-4
  delay(100);

  for (zigzag = 1; zigzag < 6; zigzag++) {                  // run 5x
    for (bits = B0001; bits <= B1000; bits <<= 1) {         // zig
      setRC4(B00, bits);
      delay(50);
    }
    for (bits = B1000; bits >= B0001; bits >>= 1) {         // zag
      setRC4(B00, bits);
      delay(50);
    }
  }
  setRC4(B000, B0000);
  delay(50);
}

void setRC4(int addr, int relays)
{
  Serial.write("!RC4", 4);
  Serial.write(addr);
  Serial.write("S");
  Serial.write(relays);
}
Title: Re: Controlling the FC-4+ with an Arduino
Post by: livinlowe on January 13, 2016, 12:35:05 PM
Can you show a picture of your setup? It's hard to know why its not working by just code. Is the 3 wire connector the same (r,w,b) on both boards?

Edit: Also, do you have to declare which pin your are transmitting serial on? Doh! Nevermind
Title: Re: Controlling the FC-4+ with an Arduino
Post by: JonnyMac on January 13, 2016, 01:30:53 PM
Our products use a half-duplex connection over one wire. Most Arduino serial libaries use two (TX and RX).

I did a bit of an Internest search (hint, hint), and came across this post:
-- http://forum.arduino.cc/index.php?topic=114553.0

You might try that library. I'm not an Arduino expert, so I shouldn't post any more code ideas.
Title: Re: Controlling the FC-4+ with an Arduino
Post by: JonnyMac on January 13, 2016, 03:42:58 PM
Update: I dug around in my box of boards and found a generation 1 RC-4 (which only works at 2400 baud). The half-duplex serial library that I found above will not compile (figures...) so I went back to using the standard SoftSerial library and only connecting to the TX pin.

This code works.

/*
* RC-4 Demo
* Jon Williams, EFX-TEK
* jwilliams@efx-tek.com
* Modified: 13 JAN 2016
*
* Interface for EFX-TEK RC-4 SSR Output Board
* -- http://www.efx-tek.com/topics/rc-4.html
*/

#include <SoftwareSerial.h>

#define RX 3    // not used
#define TX 4    // connect to RC-4 Serial.W

SoftwareSerial sio(RX, TX);


void setup()
{
  sio.begin(2400);                                          // start soft serial                               

  for (int addr = B00; addr <= B11; addr++) {               // reset all RC-4s
    setRC4(addr, B0000);
    delay(25);
  }
}

void loop()
{
  int bits, zigzag;

  for (bits = B0000; bits <= B1111; bits++) {               // counter demo
    setRC4(B00, bits);
    delay(100);
  }
  setRC4(B00, B0000);                                       // clear RC-4
  delay(100);

  for (zigzag = 1; zigzag < 6; zigzag++) {                  // run 5x
    for (bits = B0001; bits <= B1000; bits <<= 1) {         // zig
      setRC4(B00, bits);
      delay(50);
    }
    for (bits = B1000; bits >= B0001; bits >>= 1) {         // zag
      setRC4(B00, bits);
      delay(50);
    }
  }
  setRC4(B000, B0000);
  delay(50);
}

void setRC4(int addr, int relays)
{
  sio.write("!");
  sio.write("R");
  sio.write("C");
  sio.write("4");
  sio.write(addr);
  sio.write("S");
  sio.write(relays);
}
Title: Re: Controlling the FC-4+ with an Arduino
Post by: robomaster-1 on January 25, 2016, 08:22:27 PM
Using the example of the AP16 board Code , I was able to get some code that compiles of , but when downloaded in my Pro Mini board and hook it to the FC4 nothing is happening. I am at not sure on what is wrong.

Here is the code:


#include <SoftwareSerial.h>

SoftwareSerial SoftSerial(13,4);

void setup() 
{ SoftSerial.begin(2400); // start the object

  int state = 1;
  int addr = 0;
 
  // Reset Board all outputs to off 0%   
  SoftSerial.write("!FC4");
  SoftSerial.write(addr);
  SoftSerial.write("X");
 
   delay(500);
}

void loop(void)             // run over and over again
{   
   
   // Fade Channel 1 (High Resoultion Timing)
   // Fade up Channel 1  up in 1.25 seconds
  SoftSerial.write("!FC4");
  SoftSerial.write(addr);
  SoftSerial.write("FH");
  SoftSerial.write(1);
  SoftSerial.write(0);
  SoftSerial.write(255);
  SoftSerial.write(226);
  SoftSerial.write(4);
  delay(500)
 
    // Fade dowm Channel 1  up in 1.25 seconds
  SoftSerial.write("!FC4");
  SoftSerial.write(addr);
  SoftSerial.write("FH");
  SoftSerial.write(1);
  SoftSerial.write(255);
  SoftSerial.write(0);
  SoftSerial.write(226);
  SoftSerial.write(4);
  delay(500)
}


Title: Re: Controlling the FC-4+ with an Arduino
Post by: JonnyMac on January 26, 2016, 03:56:27 AM
Why do you have two WRB wires connected to the FC-4+ Serial connection? On the FC-4+, the Serial pins are tied together.

The code you posted does not compile using Arduino 1.6.6 IDE.

Didn't you tell me you prefer the Arduino because it's "easy"?....   :o

I am traveling this week and do not have an Arduino or FC-4+ with me, so I can't test this code fix, but at least it compiles.

#include <SoftwareSerial.h>

int addr = 0;

SoftwareSerial SoftSerial(13,4);

void setup() 
{
  SoftSerial.begin(2400);
  delay(10);
 
  // Reset Board all outputs to off 0%   
  SoftSerial.write("!FC4");
  SoftSerial.write(addr);
  SoftSerial.write("X");
  delay(500);
}

void loop(void)

  fade(0, 0, 255, 1250);
  delay(2000);
  fade(0, 255, 0, 1250);
  delay(2000);   
}

void fade(int ch, int startlvl, int stoplvl, int ms)
{
  SoftSerial.write("!FC4");
  SoftSerial.write(addr);
  SoftSerial.write("FH");
  SoftSerial.write(ch);
  SoftSerial.write(startlvl);
  SoftSerial.write(stoplvl);
  SoftSerial.write(ms & 0xff);
  SoftSerial.write(ms >> 8);
}


Title: Re: Controlling the FC-4+ with an Arduino
Post by: robomaster-1 on January 26, 2016, 08:02:32 AM
I want to thank you for your help. I thought this would not be to hard to do but sometimes the most simplest Idea turns out to be a little more complex than you thought. A question the TX& RX pins need to combined in order to do a half duplex mode for the board?     
Title: Re: Controlling the FC-4+ with an Arduino
Post by: livinlowe on January 26, 2016, 10:45:55 AM
Quote from: robomaster-1 on January 26, 2016, 08:02:32 AM
I want to thank you for your help. I thought this would not be to hard to do but sometimes the most simplest Idea turns out to be a little more complex than you thought. A question the TX& RX pins need to combined in order to do a half duplex mode for the board?   

No, half duplex ( and someone correct me if I'm wrong) means you just hook the transmit from your Adrinuo to the FC-4. The FC-4 doesn't communicate to the microcontroller.
Title: Re: Controlling the FC-4+ with an Arduino
Post by: JackMan on January 26, 2016, 03:18:24 PM
Quote from: livinlowe on January 26, 2016, 10:45:55 AM
No, half duplex ( and someone correct me if I'm wrong) means you just hook the transmit from your Adrinuo to the FC-4. The FC-4 doesn't communicate to the microcontroller.

I believe half duplex can execute RX and TX on a single conductor, but only one direction at a time. Full duplex can execute RX and TX simultaneously because it uses 2 conductors.
Title: Re: Controlling the FC-4+ with an Arduino
Post by: livinlowe on January 26, 2016, 03:36:00 PM
Quote from: JackMan on January 26, 2016, 03:18:24 PM
Quote from: livinlowe on January 26, 2016, 10:45:55 AM
No, half duplex ( and someone correct me if I'm wrong) means you just hook the transmit from your Adrinuo to the FC-4. The FC-4 doesn't communicate to the microcontroller.

I believe half duplex can execute RX and TX on a single conductor, but only one direction at a time. Full duplex can execute RX and TX simultaneously because it uses 2 conductors.

Oh! Okay, that makes sense.
Title: Re: Controlling the FC-4+ with an Arduino
Post by: JonnyMac on January 26, 2016, 09:50:22 PM
To Jack's point, you only need to connect one wire. As those pins are connected on the FC-4+, anything you send on your transmit pin is being fed back into your receive pin. I made and RC-4 (old one) work and I'm not even an Arduino programmer! :)
Title: Re: Controlling the FC-4+ with an Arduino
Post by: robomaster-1 on January 28, 2016, 12:55:09 AM
I tried testing this code and the FC4+ is not doing anything. I have checked all the board setting and everything is set correctly. I can't see what I am doing wrong. I am using a Pro Mini arduino board I have checked the secs on the board and it says that any pin can be used as to send and revive serial data. I am going to try a UNO Board.
Title: Re: Controlling the FC-4+ with an Arduino
Post by: JonnyMac on January 28, 2016, 05:12:41 AM
Do you have a Prop-1 controller that you can test with?

BTW... I just noticed in you picture that the FC-4+ power switch is in the OFF position.


QuoteI am going to try a UNO Board.

You know... we provide base source code for the FC-4+ -- you could always dump the schmarschmino and code the app on your FC-4+.
Title: Re: Controlling the FC-4+ with an Arduino
Post by: robomaster-1 on January 28, 2016, 03:32:54 PM
It was not on for the picture,but when I tested it was on when I was testing it and still it did nothing. I don't have a prop-1 but I think I got a prop-2 I am trying to look for it now. I do have a basic stamp 2 board with a breadboard on it and I could breadboard a serial connector for it to test FC4+ out. I should be able to use some of the test code in the FC4+ datasheet.  All I want it do is when a put a HI one of  four pins the corresponding channel will dime up and when LO dim down. Again thank you for your help on this.
Title: Re: Controlling the FC-4+ with an Arduino
Post by: JonnyMac on January 29, 2016, 05:31:11 AM
If you will provide a specification for the behavior you want from the system, I will happily code it in the FC-4+ for you. Are the specific features of the Arduino that you need? The only thing it has that the FC-4+ doesn't is ADC, but that's a simple circuit addition. Coding in Spin is so much easier than the Arduino's bastardization of C++. And you would eliminate connections between devices.

I spoke with a guy once who builds movie props. For a big movie he needed four of his little PIC boards all tied together. I joked with him by saying, "Oh... so you DO believe in multi-core -- you just want to do it the HARD way!" I showed him some of my code and he may start trying the Propeller.

If your project can be done inside the FC-4+ without an external processor, that is the way to go. You can always put the production code back in if you change your mind.
Title: Re: Controlling the FC-4+ with an Arduino
Post by: robomaster-1 on January 29, 2016, 12:02:32 PM
That is what I am doing here with Arduino Boards. What I am working is a Seance Room in which you have to solve clues in order to escape out of the room. There are four effects that got to happen in the room. Each are controlled by separate micro controllers and one master micro controller that controls the others. In the case of the Lighting Controller I wanted to keep it simple I want to have it's micro controller take four digital pins and make each dim up and down the corresponding channel 1 thru 4 . I am going to us my basic stamp-2 board of education to test out the FC4+ and if that works I will get a prop-1 form you for the final version.
Title: Re: Controlling the FC-4+ with an Arduino
Post by: livinlowe on January 29, 2016, 12:49:20 PM
I just noticed that a lot of the earlier example programs for arduino were for the RC-4 not FC-4! lol

excuse me: Yes they are, just later in the thread. ugh, ignore me
Title: Re: Controlling the FC-4+ with an Arduino
Post by: JonnyMac on January 29, 2016, 04:20:50 PM
Quote from: robomaster-1 on January 29, 2016, 12:02:32 PM
That is what I am doing here with Arduino Boards. What I am working is a Seance Room in which you have to solve clues in order to escape out of the room. There are four effects that got to happen in the room. Each are controlled by separate micro controllers and one master micro controller that controls the others. In the case of the Lighting Controller I wanted to keep it simple I want to have it's micro controller take four digital pins and make each dim up and down the corresponding channel 1 thru 4 . I am going to us my basic stamp-2 board of education to test out the FC4+ and if that works I will get a prop-1 form you for the final version.

The FC-4+ has an option port on it with four IO pins that are pulled-up to 3.3V (through 10K) but otherwise connect right into the Propeller. How were you intending to deal with these IO pins on your other microcontroller?
Title: Re: Controlling the FC-4+ with an Arduino
Post by: robomaster-1 on January 29, 2016, 08:43:04 PM
I have been going through my collection of micro controllers and I found that I have a Multicore Propeller Prototyping Board and up to now I have not used it for anything, so I could use it for the board to control the FC4+. I have not worked with a propeller board before. So you would have walk through on how to use it and under my deadline it may be the way to go. My thought is to use the other processors control the FC4+ for the various lighting channels as need for the various lighting effects for the room. 
Title: Re: Controlling the FC-4+ with an Arduino
Post by: robomaster-1 on January 30, 2016, 01:52:17 AM
I am wanting to try using my basic 2 board to run the FC4+ board, but it has been a while since I have used the Stamp environment so I am a little problem converting a stamp 1 program to a basic stamp 2. Here is the Stamp 1 program.
Thank You for your Help.

' =========================================================================
'
'   File....... FC-4+_Test.BS1
'   Purpose.... FC-4+ Features Test
'   Author..... JonnyMac
'   E-mail..... teamefx@efx-tek.com
'   Started....
'   Updated.... 01 SEP 2015
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


' -----[ Program Description ]---------------------------------------------
'
' Demonstration program for the FC-4+ IO Control Board.  All commands are
' sent to the FC-4+ through a serial link at 2400 baud (OT2400 baudmode).
' The use of the open baudmode allows boards to be daisy-chained for up to
' 16 fader outputs from one I/O pin.
'
' Configuration swtich settings
'  -- BR = off (2400 baud for Prop-1)
'  -- A1 = high bit of address
'  -- A0 = low bit of address
'  -- SM = off (for EFX-TEK serial mode)
'
' Command syntax: "!FC4", address, cmd {, data ... }
' -- where "address" is %00 (0) to %11 (3), or $FF (255) for all
' -- "cmd" is a single character
' -- optional "data" is one or more bytes
'
' Valid commands:
'
'   "!FC4", address, "X"
'     -- sets all channels to 0% (off)
'
'   "!FC4", address, "V"
'     -- requests version string from FC-4+
'     -- should be followed by SERIN to receive three-byte string
'     -- does not work with global address
'
'   "!FC4", address, "L", channel, level
'     -- sets "channel" (0..3) to "level" (0 to 255)
'        * channel is 0 to 3 (one), or "A" or $FF (all channels)
'
'   "!FC4", address, "L", "I", level0, level1, level2, level3
'     -- sets all channels individually
'     -- transmit up to four levels
'        * if less than 4 last byte must be followed by 50ms PAUSE
'
'   "!FC4", address, "L", "R", mask
'     -- randomize (0% to 100%) channel levels
'     -- only channels with "1" in "mask" bit are modified
'        * e.g., mask = %00000011 (only OUT0 -> OUT1 updated)
'
'   "!FC4", address, "D", channel, state
'     -- sets output (in "channel") to state.bit0
'        * channel is 0 to 3 (one), or "A" or $FF (all channels)
'
'   "!FC4", address, "D", "S", states, mask
'     -- sets select outputs(in "mask") digitially (off or on) to "states"
'     -- only channels with "1" in "mask" bit are modified
'
'   "!FC4", address, "D", "R", mask
'     -- digitally randomizes outputs (on or off)
'     -- only channels with "1" in "mask" bit are modified
'
'   "!FC4", address, "F", "L", channel, start, stop, seconds
'     -- fade channel from start to stop
'        * channel is 0 to 3 (one), or "A" or $FF (all channels)
'     -- duration of fade is seconds
'
'   "!FC4", address, "F", "M", channel, start, stop, tenths
'     -- fade channel from start to stop
'        * channel is 0 to 3 (one), or "A" or $FF (all channels)
'     -- duration of fade is tenths x 100ms
'
'   "!FC4", address, "F", "H", channel, start, stop, msLow, msHigh
'     -- fade channel from start to stop
'        * channel is 0 to 3 (one), or "A" or $FF (all channels)
'     -- duration of fade is milliseconds
'
'   "!FC4", address, "F", "X", chA, chB, tenths
'     -- cross fades from "chA" and "chB"
'     -- "chA" starts at 100%
'     -- "chB" starts at 0%
'     -- duration of fade is tenths x 100ms
'
'   "!FC4", address, "G", channel
'     -- retrieves present dimmer level of single channel (0 to 3)
'     -- should be followed by SERIN to receive level
'     -- does not work with global address
'
'   "!FC4", address, "I"
'     -- retrieves TTL inputs
'     -- should be followed by SERIN to receive inputs byte
'     -- does not work with global address
'
'
' Note: The ULN2803A interferes with serial transmission to FC-4+; remove
'       and replace with ULN2003A (7 channels), leaving P7 contacts open.


' -----[ Revision History ]------------------------------------------------


' -----[ I/O Definitions ]-------------------------------------------------

SYMBOL  Sio             = 7                     ' SETUP = out, no ULN


' -----[ Constants ]-------------------------------------------------------


' -----[ Variables ]-------------------------------------------------------

SYMBOL  id0             = B0                    ' version string
SYMBOL  id1             = B1
SYMBOL  id2             = B2

SYMBOL  ch              = B3
SYMBOL  level           = B4

SYMBOL  idx             = B5

SYMBOL  timing          = W5
SYMBOL   tmLo           =  B10
SYMBOL   tmHi           =  B11


' -----[ Initialization ]--------------------------------------------------

Reset:
  PAUSE 1500                                    ' let FC-4+ boot up
  SEROUT Sio, OT2400, ("!FC4", %00, "X")        ' reset FC-4+


' -----[ Program Code ]----------------------------------------------------

Main:
  SEROUT Sio, OT2400, ("!FC4", %00, "V")        ' get version
  SERIN  Sio, OT2400, id0, id1, id2

  DEBUG CLS
  DEBUG "FC-4+ Version ", #@id0, #@id1, #@id2, CR
  PAUSE 500


Test:
  ' digital control of single channel
  FOR ch = 0 TO 3
    SEROUT Sio, OT2400, ("!FC4", %00, "D", ch, 1)
    PAUSE 250
  NEXT

  FOR ch = 0 TO 3
    SEROUT Sio, OT2400, ("!FC4", %00, "D", ch, 0)
    PAUSE 250
  NEXT

  ' level randomize all outputs

  FOR idx = 1 TO 100
    SEROUT Sio, OT2400, ("!FC4", %00, "L", "R", %1111)
  NEXT

  SEROUT Sio, OT2400, ("!FC4", %00, "X")
  PAUSE 1000

  ' cross-fade from OUT0 to OUT1 in 3 seconds
  SEROUT Sio, OT2400, ("!FC4", %00, "F", "X", 0, 1, 30)

  ' cross-fade from OUT3 to OUT2 in 3 seconds
  SEROUT Sio, OT2400, ("!FC4", %00, "F", "X", 3, 2, 30)

Wait1:
  ' check status of channel 3
  ' -- wait for x-fade to finish
  SEROUT Sio, OT2400, ("!FC4",  %00, "G", 3)
  SERIN  Sio, OT2400, level
  IF level > 0 THEN Wait1


  ' cross-fade from OUT1 to OUT0 in 3 seconds
  SEROUT Sio, OT2400, ("!FC4", %00, "F", "X", 1, 0, 30)

  ' cross-fade from OUT2 to OUT3 in 3 seconds
  SEROUT Sio, OT2400, ("!FC4", %00, "F", "X", 2, 3, 30)

Wait2:
  ' check status of channel 2
  ' -- wait for x-fade to finish
  SEROUT Sio, OT2400, ("!FC4", %00, "G", 2)
  SERIN  Sio, OT2400, level
  IF level > 0 THEN Wait2
  PAUSE 500

  SEROUT Sio, OT2400, ("!FC4", $FF, "X")        ' global address
  PAUSE 500

  GOTO Test


' -----[ Subroutines ]-----------------------------------------------------


' -----[ EEPROM Data ]-----------------------------------------------------
Title: Re: Controlling the FC-4+ with an Arduino
Post by: JonnyMac on January 30, 2016, 06:51:55 AM
QuoteI have been going through my collection of micro controllers and I found that I have a Multicore Propeller Prototyping Board and up to now I have not used it for anything, so I could use it for the board to control the FC4+.

What you could do is just reprogram the FC-4+ to do what you want -- we support that (and I don't know how many times I have to say it). Why add another controller to the mix when you can do everything in one place? If you'll define what you want, I'll write the code -- your client doesn't need to know that I did it for you.
Title: Re: Controlling the FC-4+ with an Arduino
Post by: robomaster-1 on January 30, 2016, 09:44:32 AM
I loaded the program into my board of education hooked up to the FC4+ and nothing was displayed on the debug screen. I checked the board setting and as far as I can tell everything is set right. Do I need to hook up he AC side to see this or can I see the LEDs on the board ranping up and down? Do I have a bad board?
Title: Re: Controlling the FC-4+ with an Arduino
Post by: JonnyMac on January 30, 2016, 10:06:25 AM
We test all boards before shipping, but if you want to send it back for a check you can do that. You need to call John B at the sales number and get an RMA.
Title: Re: Controlling the FC-4+ with an Arduino
Post by: robomaster-1 on January 30, 2016, 01:48:36 PM
You told me earlier that you can reprogram the board to run without a microcontroller. I like to do that . So here's how I like it to work. Using for the pins I want each one to dim up whe that is Hi and dim down when Low. That all I need it to do for now. I should be able to see the LEDs dim up and down with hooking AC power side up right?
Title: Re: Controlling the FC-4+ with an Arduino
Post by: JonnyMac on January 30, 2016, 11:02:39 PM
You need to have AC connected because the dimmer is synced to the AC line frequency; you cannot dim AC without that synchronization.
Title: Re: Controlling the FC-4+ with an Arduino
Post by: robomaster-1 on February 02, 2016, 12:45:17 PM
Thanks for help on the FC4+, I thought since it has optoinsulators on the board  I could see it work by seeing the LED's rampaging up and down without hook in the AC power lines. I will now wire up the AC power on channel 1 to test the board. I thinking that my original arduino is OK.
Title: Re: Controlling the FC-4+ with an Arduino
Post by: JonnyMac on February 02, 2016, 05:41:45 PM
AC dimming is a very different animal from DC -- I've written about it in Nuts & Volts. AC sync is a requirement because dimming involves starting into the AC-half cycle; the dimmer the output, the later into the cycle you enable the triac.
Title: Re: Controlling the FC-4+ with an Arduino
Post by: robomaster-1 on February 03, 2016, 10:33:52 PM
Got it working I feel really dumb for not connecting the AC Power side up. You said earlier that up could set up some the pins to dim up or down when the pin goes hi dim up low dim down for four pins. So I won't to use a processor to control it. Is this still possible?
Here a YouTube link on seeing my test set up working.

https://youtu.be/WfJ2dGDYXVg
Title: Re: Controlling the FC-4+ with an Arduino
Post by: JonnyMac on February 04, 2016, 08:05:10 AM
Quote from: robomaster-1 on February 03, 2016, 10:33:52 PM
Got it working I feel really dumb for not connecting the AC Power side up. You said earlier that up could set up some the pins to dim up or down when the pin goes hi dim up low dim down for four pins. So I won't to use a processor to control it. Is this still possible?
Here a YouTube link on seeing my test set up working.

https://youtu.be/WfJ2dGDYXVg

Yes, it's possible, but you must be very specific. We charge our commercial customers $125/hour for programming at this level. If you want me to do that in the forums, then you must spell out exactly what you want, to the finest degree. We have a programming template for the FC-4+ (in the hacking section which is where this project should move) that will get you started. I've done the hard work of creating AC faders and a fade manager that lets you tell a channel how to fade (from one level to another and how long to take). All you have to do is spell out what the buttons do.
Title: Re: Controlling the FC-4+ with an Arduino
Post by: robomaster-1 on February 04, 2016, 01:20:41 PM
For the right now I will stick with the Basic Stamp 2. Do you know of a local source for the Super Carrier Board? I need get this all working quickly. I want to thank you for all your help in get the board working.
Title: Re: Controlling the FC-4+ with an Arduino
Post by: robomaster-1 on February 04, 2016, 02:54:13 PM
It has been a while since I used the basic stamp environment I seem to recall that there is a way to tell it to auto run the program when the power is turned on. I have to push the reset button on the board in order to get the program working as of now.   
Title: Re: Controlling the FC-4+ with an Arduino
Post by: JonnyMac on February 04, 2016, 04:52:21 PM
All BASIC Stamps run the last program downloaded. Nothing else is necessary. Disconnect any programming cable before running your stand-alone test.
Title: Re: Controlling the FC-4+ with an Arduino
Post by: robomaster-1 on February 05, 2016, 09:29:41 AM
Then explain to why when I turn off the power to the whole system and turn it back on the program does not start right back up?
Title: Re: Controlling the FC-4+ with an Arduino
Post by: JackMan on February 05, 2016, 10:06:23 AM
Quote from: robomaster-1 on February 05, 2016, 09:29:41 AM
Then explain to why when I turn off the power to the whole system and turn it back on the program does not start right back up?
Pressing the reset button has the exact same effect as powering down and back up, it restarts the program from the beginning.  I'm confused as to why the program will run if you press the reset button but not when you power up. You really need to post your code so we can see if the problem is there.
Title: Re: Controlling the FC-4+ with an Arduino
Post by: robomaster-1 on February 05, 2016, 10:28:32 AM
Here is the code I am using. What was trying to say the program works fine,but when I turn off  all the power to the system this includes the FC4+ and the basic stamp board and then turn back on the program in the stamp does not run and I have to rest the board in order to start it back up. Here is the code.

' =========================================================================
'
'   File....... FC-4+_Test.BS2
'   Purpose.... FC-4+ Features Test
'   Author..... JonnyMac
'   E-mail..... teamefx@efx-tek.com
'   Started....
'   Updated.... 01 FEB 2016
'
'   {$STAMP BS2}
'   {$PBASIC 2.5}
'
' =========================================================================


' -----[ Program Description ]---------------------------------------------
'
' Demonstration program for the FC-4+ IO Control Board.  All commands are
' sent to the FC-4+ through a serial link at 2400 baud (Baud baudmode).
' The use of the open baudmode allows boards to be daisy-chained for up to
' 16 fader outputs from one I/O pin.
'
' Configuration swtich settings
'  -- BR = on (2400 baud for Prop-2)
'  -- A1 = high bit of address
'  -- A0 = low bit of address
'  -- SM = off (for EFX-TEK serial mode)
'
' Command syntax: "!FC4", address, cmd {, data ... }
' -- where "address" is %00 (0) to %11 (3), or $FF (255) for all
' -- "cmd" is a single character
' -- optional "data" is one or more bytes
'
' Valid commands:
'
'   "!FC4", address, "X"
'     -- sets all channels to 0% (off)
'
'   "!FC4", address, "V"
'     -- requests version string from FC-4+
'     -- should be followed by SERIN to receive three-byte string
'     -- does not work with global address
'
'   "!FC4", address, "L", channel, level
'     -- sets "channel" (0..3) to "level" (0 to 255)
'        * channel is 0 to 3 (one), or "A" or $FF (all channels)
'
'   "!FC4", address, "L", "I", level0, level1, level2, level3
'     -- sets all channels individually
'     -- transmit up to four levels
'        * if less than 4 last byte must be followed by 50ms PAUSE
'
'   "!FC4", address, "L", "R", mask
'     -- randomize (0% to 100%) channel levels
'     -- only channels with "1" in "mask" bit are modified
'        * e.g., mask = %00000011 (only OUT0 -> OUT1 updated)
'
'   "!FC4", address, "D", channel, state
'     -- sets output (in "channel") to state.bit0
'        * channel is 0 to 3 (one), or "A" or $FF (all channels)
'
'   "!FC4", address, "D", "S", states, mask
'     -- sets select outputs(in "mask") digitially (off or on) to "states"
'     -- only channels with "1" in "mask" bit are modified
'
'   "!FC4", address, "D", "R", mask
'     -- digitally randomizes outputs (on or off)
'     -- only channels with "1" in "mask" bit are modified
'
'   "!FC4", address, "F", "L", channel, start, stop, seconds
'     -- fade channel from start to stop
'        * channel is 0 to 3 (one), or "A" or $FF (all channels)
'     -- duration of fade is seconds
'
'   "!FC4", address, "F", "M", channel, start, stop, tenths
'     -- fade channel from start to stop
'        * channel is 0 to 3 (one), or "A" or $FF (all channels)
'     -- duration of fade is tenths x 100ms
'
'   "!FC4", address, "F", "H", channel, start, stop, msLow, msHigh
'     -- fade channel from start to stop
'        * channel is 0 to 3 (one), or "A" or $FF (all channels)
'     -- duration of fade is milliseconds
'
'   "!FC4", address, "F", "X", chA, chB, tenths
'     -- cross fades from "chA" and "chB"
'     -- "chA" starts at 100%
'     -- "chB" starts at 0%
'     -- duration of fade is tenths x 100ms
'
'   "!FC4", address, "G", channel
'     -- retrieves present dimmer level of single channel (0 to 3)
'     -- should be followed by SERIN to receive level
'     -- does not work with global address
'
'   "!FC4", address, "I"
'     -- retrieves TTL inputs
'     -- should be followed by SERIN to receive inputs byte
'     -- does not work with global address
'
'
' Note: The ULN2803A interferes with serial transmission to FC-4+; remove
'       and replace with ULN2003A (7 channels), leaving P15 contacts open.


' -----[ Revision History ]------------------------------------------------


' -----[ I/O Definitions ]-------------------------------------------------

Sio             PIN     12                    ' no ULN, SETUP = UP


' -----[ Constants ]-------------------------------------------------------

#SELECT $STAMP
  #CASE BS2, BS2E, BS2PE
    T2400       CON     396
    T38K4       CON     6
  #CASE BS2SX, BS2P
    T2400       CON     1021
    T38K4       CON     45
  #CASE BS2PX
    T2400       CON     1646
    T38K4       CON     84
#ENDSELECT

SevenBit        CON     $2000
Inverted        CON     $4000
Open            CON     $8000
Baud            CON     Open + T38K4            ' baud jumper out

Addr            CON     %00                     ' both address jumpers out

Yes             CON     1
No              CON     0


' -----[ Variables ]-------------------------------------------------------

id0             VAR     Byte                 ' version string
id1             VAR     Byte
id2             VAR     Byte

ch              VAR     Byte
level           VAR     Byte
idx             VAR     Byte


' -----[ Initialization ]--------------------------------------------------

Reset:
  PAUSE 1500                                    ' let FC-4+ boot up
  SEROUT Sio, Baud, ["!FC4", Addr, "X"]         ' reset FC-4+


' -----[ Program Code ]----------------------------------------------------

Main:
  SEROUT Sio, Baud, ["!FC4", Addr, "V"]         ' get version
  SERIN  Sio, Baud, [STR id0\3]

  DEBUG CLS
  DEBUG "FC-4+ Version ", id0, ".", id1, id2, CR, CR
  PAUSE 1000

Test:
  ' digital control of single channel
  FOR ch = 0 TO 3
    SEROUT Sio, Baud, ["!FC4", %00, "D", ch, 1]
    PAUSE 250
  NEXT

  FOR ch = 0 TO 3
    SEROUT Sio, Baud, ["!FC4", Addr, "D", ch, 0]
    PAUSE 250
  NEXT

  ' level randomize all outputs

  FOR idx = 1 TO 100
    SEROUT Sio, Baud, ["!FC4", Addr, "L", "R", %1111]
    PAUSE 25
  NEXT

  SEROUT Sio, Baud, ["!FC4", Addr, "X"]
  PAUSE 1000

  ' cross-fade from OUT0 to OUT1 in 3 seconds
  SEROUT Sio, Baud, ["!FC4", Addr, "F", "X", 0, 1, 30]

  ' cross-fade from OUT3 to OUT2 in 3 seconds
  SEROUT Sio, Baud, ["!FC4", Addr, "F", "X", 3, 2, 30]

Wait1:
  ' check status of channel 3
  ' -- wait for x-fade to finish
  DO
    SEROUT Sio, Baud, ["!FC4",  Addr, "G", 3]
    SERIN  Sio, Baud, [level]
  LOOP UNTIL (level = 0)


  ' cross-fade from OUT1 to OUT0 in 3 seconds
  SEROUT Sio, Baud, ["!FC4", Addr, "F", "X", 1, 0, 30]

  ' cross-fade from OUT2 to OUT3 in 3 seconds
  SEROUT Sio, Baud, ["!FC4", Addr, "F", "X", 2, 3, 30]

Wait2:
  ' check status of channel 2
  ' -- wait for x-fade to finish
  DO
    SEROUT Sio, Baud, ["!FC4", Addr, "G", 2]
    SERIN  Sio, Baud, [level]
  LOOP UNTIL (level = 0)
  PAUSE 500

  SEROUT Sio, Baud, ["!FC4", $FF, "X"]        ' global address
  PAUSE 500

  GOTO Test


' -----[ Subroutines ]-----------------------------------------------------


' -------------------------------------------------------------------------


' -----[ User Data ]-------------------------------------------------------
Title: Re: Controlling the FC-4+ with an Arduino
Post by: JackMan on February 05, 2016, 10:33:50 AM
Could it be that 1.5 seconds is not enough time for the FC-4 to boot up?
Title: Re: Controlling the FC-4+ with an Arduino
Post by: JonnyMac on February 05, 2016, 10:34:59 AM
Sure, blame it on me! :)

1) We provide demonstration code AS IS, with no warranty of suitability for any purpose -- as ever, we encourage customers to write their own code and not rely on ours. What works for us may not work for you.

2) Inserting a PAUSE 2000 at the beginning of the BASIC Stamp program may be helpful. This will allow the Propeller on the FC-4+ to boot up and get in sync with the line frequency.
Title: Re: Controlling the FC-4+ with an Arduino
Post by: JonnyMac on February 05, 2016, 10:47:08 AM
Quote from: robomaster-1 on January 26, 2016, 08:02:32 AM
I want to thank you for your help. I thought this would not be to hard to do but sometimes the most simplest Idea turns out to be a little more complex than you thought. A question the TX& RX pins need to combined in order to do a half duplex mode for the board? 

None of this is difficult -- heck, if I can do it, anybody can.

The FC-4+ uses half-duplex communications; this means that it sends and retrieves on one wire (by the way, this is an industry definition, not ours). In this case the RX and TX markings on the FC-4+ are meaningless; in fact, in production they are connected together (you have to modify the board and reprogram it for full-duplex).

The BASIC Stamp and other processors can also communicate in half-duplex mode.

Turns out that the Arduino -- which everybody says is wonderful but very few can actually program! -- does not do half-duplex by default, you have to use a software serial library. I tried one and it didn't work. I didn't go any further because we are not in business to sell or support Arduino microcontrollers. Our documentation provides all the information required for a programmer with the proper experience to connect to them. I have worked with several Hollywood prop builders who use the Arduino to control our products (primarily the AP-16+) -- they just send commands and did not need feedback.

Some have said you can connect a 4.7K resistor between the Arduino RX and TX pins to get it to act like a half-duplex connection. If you do this you'll have to remember to flush the receive buffer after you transmit a command.
Title: Re: Controlling the FC-4+ with an Arduino
Post by: JonnyMac on February 05, 2016, 11:09:01 AM
Okay, hate to break the news... but we have another case of operator error.

I dragged out my FC-4+ test platform, loaded the production code that you have (I'm working on an update) into it, then connected a Prop-2 (BASIC Stamp 2) and ran the test program. The only thing I changed is the SIO pin (I use 15 on the Prop-2).

1) Downloaded the program to the Prop-2 and everything works.

2) Disconnected DC power to Prop-2 and FC-4+, then powered back up. Everything works.

3) Killed power to strip that was providing AC to FC-4, and DC (via power supplies) to the FC+4+ and Prop-2, the powered back up. Everything works.
Title: Re: Controlling the FC-4+ with an Arduino
Post by: robomaster-1 on February 05, 2016, 11:36:26 AM
I changed the SIO to pin 15 and downloaded back on my basic stamp 2 board education and now it works fine and when I kill the power by turning off my power strip and then turning it back it all starts up and work. I have not worked the basic stamp in a while I am a little rusty. I will be ordering a prop-1 to finish up this project. All I got to do is write a program using four pins to when each are Hi that channel dims up and when low the that channel dims down.  Thank You for all your help.
Title: Re: Controlling the FC-4+ with an Arduino
Post by: JackMan on February 05, 2016, 11:55:52 AM
OK, so what was the problem? It couldn't have been simply changing the SIO from pin 12 to pin 15, could it?
Title: Re: Controlling the FC-4+ with an Arduino
Post by: robomaster-1 on February 05, 2016, 12:16:09 PM
I don't know that's all I did change that maybe something with board of education. You got me but it not having that problem.
Title: Re: Controlling the FC-4+ with an Arduino
Post by: JackMan on February 05, 2016, 02:50:38 PM
Quote from: JackMan on February 05, 2016, 11:55:52 AM
OK, so what was the problem? It couldn't have been simply changing the SIO from pin 12 to pin 15, could it?

Any input on this Jon?
Title: Re: Controlling the FC-4+ with an Arduino
Post by: robomaster-1 on February 05, 2016, 05:50:04 PM
I have ordered a prop-1 so I can complete the light dimmer controller. I am going to make one more try with an Arduino board. I will use my UNO board just want to know if can control the FC4+ board.
Title: Re: Controlling the FC-4+ with an Arduino
Post by: JonnyMac on February 06, 2016, 10:36:19 AM
We have established several times that one can control EFX-TEK boards from an Arduino. You simply have to send commands -- getting information (status) back requires a half-duplex connection from the Arduino which may exist, but we know nothing about. Half duplex control is up to you.

Remember that the Prop-1 has a very small memory so you'll want to keep your program fairly simple.
Title: Re: Controlling the FC-4+ with an Arduino
Post by: robomaster-1 on February 07, 2016, 03:01:56 AM
I am going to keep it simple. I am using four pins. For example when pin 1 is HI channel 1 will dim up and stay up until the pin is a LOW. The same for the other 3 pins. It does not need to complex for this application. Again thank you all help on this.
Title: Re: Controlling the FC-4+ with an Arduino
Post by: robomaster-1 on February 08, 2016, 01:20:31 AM
Since I now have the AC hooked I decided to try using the Arduino board one last time. So I uploaded a simple fade a channel  up then down code from earlier in this post. I works fine I feel so dumb for not hooking the AC Power sooner. I am going to developed the code I need tomorrow and use the prop-1 as a back up board I will program it to do the same code. Thank you for all your help on this guy's.
Title: Re: Controlling the FC-4+ with an Arduino
Post by: livinlowe on February 09, 2016, 11:04:38 AM
Quote from: robomaster-1 on February 08, 2016, 01:20:31 AM
Since I now have the AC hooked I decided to try using the Arduino board one last time. So I uploaded a simple fade a channel  up then down code from earlier in this post. I works fine I feel so dumb for not hooking the AC Power sooner. I am going to developed the code I need tomorrow and use the prop-1 as a back up board I will program it to do the same code. Thank you for all your help on this guy's.
Hmm, as an intellectual challenge I tried getting my arduino to talk to my FC-4 and also got no results. However, I think I made the same error you did by not connecting AC power to my FC-4. When I get some time I will confirm and let you know
Title: Re: Controlling the FC-4+ with an Arduino
Post by: JonnyMac on February 09, 2016, 04:59:11 PM
For the moment, you need to have the AC present or else the program gets stuck waiting for the line for the ZC signal so it can measure the line frequency. I have some ideas for working around this -- let me think about it.
Title: Re: Controlling the FC-4+ with an Arduino
Post by: robomaster-1 on February 10, 2016, 04:00:39 PM
I have been trying  to get it to dim up and down when pin 2 is made HI or LOW. It is not seeing the pin at all just fades up and down. Was able to create a cross fade function and it works.

Here is my code:

#include <SoftwareSerial.h>

int addr = 0;
const int DimPin1 = 2;  //Dimmer Pin 2 Channel 1 on FC4+
const int DimPin2 = 3;  //Dimmer Pin 3 Channel 2 on FC4+
const int DimPin3 = 4;  //Dimmer Pin 4 Channel 3 on FC4+
const int DimPin4 = 5;  //Dimmer Pin 3 Channel 4 on FC4+

SoftwareSerial SoftSerial(13,12);// RX , TX

void setup() 
{
  SoftSerial.begin(38400);
  delay(10);

  // Setting up the Pins
  pinMode(DimPin1, INPUT);  // Setting Pins as Inputs
  pinMode(DimPin2, INPUT);
  pinMode(DimPin3, INPUT);
  pinMode(DimPin4, INPUT);
 
  digitalWrite(DimPin1,HIGH);  // turn on internal pull-up on the inputPin

 
  // Reset Board all outputs to off 0%   
  SoftSerial.write("!FC4");
  SoftSerial.write(addr);
  SoftSerial.write("X");
  delay(500);
}

void loop(){
int val = digitalRead(DimPin1); // read input value
if (val == HIGH) // check if the input is HIGH
{
fade(0, 255, 0, 1250);  // Dim Down Channel 1
  delay(6000);
}
else
{
fade(0, 0, 255, 1250);  // Dim Up Channel 1
  delay(6000);
}
}


// FC4+  Funtions

void fade(int ch, int startlvl, int stoplvl, int ms)
{
  SoftSerial.write("!FC4");
  SoftSerial.write(addr);
  SoftSerial.write("FH");
  SoftSerial.write(ch);
  SoftSerial.write(startlvl);
  SoftSerial.write(stoplvl);
  SoftSerial.write(ms & 0xff);
  SoftSerial.write(ms >> 8);
}

Cross Fade Function:

// "!FC4", address, "FX", chA, chB, tenths
//    -- cross fades from "chA" and "chB"
//     -- "chA" starts at 100%
//     -- "chB" starts at 0%
//    -- duration of fade is tenths x 100ms

void cfade(int chA, int chB, int tenths)
{
  SoftSerial.write("!FC4");
  SoftSerial.write(addr);
  SoftSerial.write("FX");
  SoftSerial.write(chA);
  SoftSerial.write(chB);
  SoftSerial.write(tenths);
}
Title: Re: Controlling the FC-4+ with an Arduino
Post by: JonnyMac on February 11, 2016, 09:52:24 AM
Please remember that we use Parallax processors and have very little expertise in the Arduino -- you should probably seek assistance in the Arduino forums.

One tip I will offer is that you'll want to get rid of the delay(6000) calls as these will block your program for six seconds. What if you want to start fading up one channel, then start the next two seconds later? Using blocking code prevents this.

The Arduino has a millis() timer that lets you check the elapsed time between events. I suggest you create timer variables for each channel and initialize them to 6000. You'll also want a state variable for each channel. In your main loop you use the timer and millis() to see if it's okay to look at the channel switch. When at least 6000ms have passed, then the state of the switch is checked; it it differs from the channel state then the channel is faded as required and the state is updated.

THIS CODE IS NOT TESTED

void loop()
{
  if ((millis() - timer1) >= 6000) {            // okay to check ch1?
    if (ch1state == LOW) {
      if (digitalRead(CH1FADE) == HIGH) {
         fade(0, 0, 255, 1250);
         ch1state = HIGH;
         timer1 = millis();                     // set new sync point
      }
    else {
      if (digitalRead(CH1FADE) == LOW) {
         fade(0, 255, 0, 1250);
         ch1state = LOW;
         timer1 = millis();
      }
    }
  }

  // other channels here

}
Title: Re: Controlling the FC-4+ with an Arduino
Post by: robomaster-1 on February 14, 2016, 06:01:27 AM
Here is what I want to do for this project. I need to use four digital pins to do the following when the pin is brought HI it dims up that channel when brought LOW that channel dims down. So if you were using a Basic Stamp 2 how would this be coded. The arduino functions you have shown earlier have been tested and the work on my arduino boards. I want to Thank You for all your help on this topic.
Title: Re: Controlling the FC-4+ with an Arduino
Post by: bsnut on February 15, 2016, 08:48:32 PM
Quote from: robomaster-1 on February 14, 2016, 06:01:27 AM
Here is what I want to do for this project. I need to use four digital pins to do the following when the pin is brought HI it dims up that channel when brought LOW that channel dims down. So if you were using a Basic Stamp 2 how would this be coded. The arduino functions you have shown earlier have been tested and the work on my arduino boards. I want to Thank You for all your help on this topic.
It is easy to do on the Prop-2 (Basic Stamp 2 processor board) and be happy to show you how to code it. Are you going to start a new topic in the Prop-2 section of the forums?