May 06, 2024, 09:24:55 PM

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

robomaster-1

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

JonnyMac

You need to have AC connected because the dimmer is synced to the AC line frequency; you cannot dim AC without that synchronization.
Jon McPhalen
EFX-TEK Hollywood Office

robomaster-1

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

JonnyMac

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

robomaster-1

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

JonnyMac

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

robomaster-1

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

robomaster-1

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

JonnyMac

All BASIC Stamps run the last program downloaded. Nothing else is necessary. Disconnect any programming cable before running your stand-alone test.
Jon McPhalen
EFX-TEK Hollywood Office

robomaster-1

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

JackMan

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.

robomaster-1

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

JackMan

Could it be that 1.5 seconds is not enough time for the FC-4 to boot up?

JonnyMac

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

JonnyMac

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