User Tools

Site Tools


tiger_programmable_logic_card

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
tiger_programmable_logic_card [2019/05/09 17:02]
asiadmin [Clock]
tiger_programmable_logic_card [2019/05/24 16:54]
jon
Line 232: Line 232:
 ==== Clock ==== ==== Clock ====
  
-To create a free-running clock with user-selectable period and duty cycle you can combine ​a NRT delay cell and a one-shot. ​ The delay cell trigger is connected to logic high, but because it is non-retriggerable it will simply trigger itself whenever ​the delay has finished, thus outputting a pulse once per delay period. ​ That pulse triggers a one-shot which generates the clock output, and the one-shot ​duration sets the time the output signal is high (i.e. the duty cycle is the ratio of the one-shot duration with the delay period).+To create a free-running clock with user-selectable period and duty cycle you can combine ​two non-retriggerable ​one-shot ​cells.  The first cell'​s ​trigger is connected to logic high, but because it is non-retriggerable it will simply trigger itself whenever ​it has, thus outputting a pulse once per delay period. ​ That pulse triggers a second ​one-shot which generates the clock output ​whose duration sets the time the output signal is high (i.e. the duty cycle is the ratio of the one-shot duration with the delay period).  From the 4kHz internal clock it is possible to generate up to 2kHz clock by this means.
  
---> Script: clock signal on BNC1 output #+--> Script: clock signal on BNC3 output #
 <code java> <code java>
 // generate a clock signal based on the internal 4kHz clock, e.g. for triggering a camera // generate a clock signal based on the internal 4kHz clock, e.g. for triggering a camera
-// currently hard-codes using cells 1 and 2 and BNC output #1+// currently hard-codes using cells 1 and 2 and BNC output #3
  
 // variables to be edited by user // variables to be edited by user
-double clockFrequencyHz = 100.0;  // clock frequency in Hertz+double clockFrequencyHz = 100;  // clock frequency in Hertz
 double clockDutyCycle = 0.5;     // should be between 0 and 1 exclusive double clockDutyCycle = 0.5;     // should be between 0 and 1 exclusive
  
Line 254: Line 254:
 String propUpdates = "​EditCellUpdateAutomatically";​ String propUpdates = "​EditCellUpdateAutomatically";​
 String valNo = "​No";​ String valNo = "​No";​
-String valDelayNRT = "15 - delay (NRT)";​ 
 String valOneShotNRT = "14 - one shot (NRT)";​ String valOneShotNRT = "14 - one shot (NRT)";​
 int addrInvert= 64; int addrInvert= 64;
 int addrEdge = 128; int addrEdge = 128;
 double ticsPerSecond = 4000.0; double ticsPerSecond = 4000.0;
-int addrOutputBNC1 ​33;+int addrOutputBNC3 ​35;
 int addrDelayNRT = 1; int addrDelayNRT = 1;
 int addrOneShot = 2; int addrOneShot = 2;
  
 // figure out the cycle period and high period in terms of PLC "​tics"​ (4kHz) // figure out the cycle period and high period in terms of PLC "​tics"​ (4kHz)
-int clockPeriodTics = (int) (ticsPerSecond/​clockFrequencyHz + 0.5) - 2+int clockPeriodTics = (int) (ticsPerSecond/​clockFrequencyHz + 0.5)
-int clockHighTics = (int) (clockPeriodTics * clockDutyCycle) ​+ 1;+print("​have " + (clockPeriodTics-1) + " (+1) tics in one-shot for actual frequency of " + ticsPerSecond/​(clockPeriodTics))
 +int clockHighTics = (int) (clockPeriodTics * clockDutyCycle);​
  
 // turn off updates to speed communication // turn off updates to speed communication
Line 273: Line 273:
 // do programming of one-shot and delay cells // do programming of one-shot and delay cells
 mmc.setProperty(plcName,​ propPosition,​ addrDelayNRT);​ mmc.setProperty(plcName,​ propPosition,​ addrDelayNRT);​
-mmc.setProperty(plcName,​ propCellType, ​valDelayNRT); +mmc.setProperty(plcName,​ propCellType, ​valOneShotNRT); 
-mmc.setProperty(plcName,​ propCellConfig,​ clockPeriodTics);​+mmc.setProperty(plcName,​ propCellConfig, ​(clockPeriodTics-1));
 mmc.setProperty(plcName,​ propCellInput1,​ addrInvert + addrEdge); ​ // trigger cell as fast as we can, but NRT prevents re-triggering when active mmc.setProperty(plcName,​ propCellInput1,​ addrInvert + addrEdge); ​ // trigger cell as fast as we can, but NRT prevents re-triggering when active
 mmc.setProperty(plcName,​ propCellInput2,​ addrInvert + addrEdge); ​ // clock on every tic mmc.setProperty(plcName,​ propCellInput2,​ addrInvert + addrEdge); ​ // clock on every tic
Line 285: Line 285:
  
 // connect to BNC output // connect to BNC output
-mmc.setProperty(plcName,​ propPosition, ​addrOutputBNC1);+mmc.setProperty(plcName,​ propPosition, ​addrOutputBNC3);
 mmc.setProperty(plcName,​ propCellConfig,​ addrOneShot);​ mmc.setProperty(plcName,​ propCellConfig,​ addrOneShot);​
  
 // restore updates // restore updates
 mmc.setProperty(plcName,​ propUpdates,​ valUpdatesOriginal);​ mmc.setProperty(plcName,​ propUpdates,​ valUpdatesOriginal);​
 +
 +
 +
 +
 </​code>​ </​code>​
 <-- <--
Address: 29391 W Enid Rd. Eugene, OR 97402, USA | Phone: +1 (541) 461-8181
tiger_programmable_logic_card.txt · Last modified: 2019/06/20 18:10 by jon