November 22, 2024, 10:22:32 AM

News:

Be sure to checkout our Vixen interfaces in the Library forum -- if you want PC automation at near zero cost, EFX-TEK and Vixen is a great combination of tools.


Controlling the FC-4+ with an Arduino

Started by robomaster-1, November 03, 2015, 10:12:10 AM

Previous topic - Next topic

JonnyMac

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.
Jon McPhalen
EFX-TEK Hollywood Office

robomaster-1

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.
Tim J. Lewis
Magic and Technology

JackMan

OK, so what was the problem? It couldn't have been simply changing the SIO from pin 12 to pin 15, could it?

robomaster-1

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.
Tim J. Lewis
Magic and Technology

JackMan

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?

robomaster-1

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.
Tim J. Lewis
Magic and Technology

JonnyMac

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.
Jon McPhalen
EFX-TEK Hollywood Office

robomaster-1

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.
Tim J. Lewis
Magic and Technology

robomaster-1

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.
Tim J. Lewis
Magic and Technology

livinlowe

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
Shawn
Scaring someone with a prop you built -- priceless!

JonnyMac

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.
Jon McPhalen
EFX-TEK Hollywood Office

robomaster-1

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);
}
Tim J. Lewis
Magic and Technology

JonnyMac

February 11, 2016, 09:52:24 AM #57 Last Edit: February 11, 2016, 12:33:35 PM by JonnyMac
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

}
Jon McPhalen
EFX-TEK Hollywood Office

robomaster-1

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.
Tim J. Lewis
Magic and Technology

bsnut

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?
William Stefan
The Basic Stamp Nut