3/17/2009 2:24 PM  
Joined: 3/17/2009 Last visit: 4/19/2011 Posts: 10 Rating: (0) 
We're about to start a project and I'm given the task of PLC programming. I want to create an analog output that varies from 010V in a sine wave (f=0.1Hz). Is that possible with a PLC, either as an already built in command or do I need to create a table that states the correct voltage at a given time and incorporate that somehow? 
3/17/2009 2:29 PM  
Joined: 9/28/2005 Last visit: 7/6/2017 Posts: 2954 Rating: (225) 
Hi, With Step7 CPU you have sine function "SIN" which returns sine value of given angle in radians. Maybe this will be helpful. In general, you must calculate 2pi radians (360 degres) in 0.1 seconds. If you want to get an value every degree then you must recalculate sine every 0.1/360 seconds = 0.28 ms. Basically you must get full sine in 100 ms. Its too fast I think.... You wont get nice sine from output I think.... You need high speed analog output and use interrupts. Even if you recalculate sine every 90 degrees then you must do calculation every 25ms and you'll get only 4 points of sine function. Please correct me if I'm wrong. 
Last edited by: Darius at: 3/17/2009 2:46 PMLast edited by: Darius at: 3/17/2009 2:43 PMBest regards, 

3/17/2009 11:46 PM  
Joined: 7/2/2008 Last visit: 8/17/2017 Posts: 889 Rating: (273) 
Hi, Please correct me if I'm wrong. F (Hz)= 1/T where T isperiod(Time)in seconds. If the frequency is 0.1 Hz, this means that T= 1/F = 1/0.1 = 10 seconds. So, you want to generate a sine wave that completes a single cycle (360 degree) in 10 seconds. isn't it? I think you need to construct a table that includes output values (Sine samples)along the complete cycle. You should write a code to output these values at cyclic intervals. The point is that you want to adjust number of samples with cycle interval. I mean if you want to generate 360 samples (360 degree) at the frequency 0.1 Hz (10 seconds), then you should have a cycle time of 27.7 msec which you can't get (you can't get 0.7 msec). If yougo with 28 seconds then you will change the frequency by 1.1%. I recommend to have 400 samples at cycle interval of 25 msec. Best regards. HH 
This contribution was helpful to1 thankful Users 
3/18/2009 7:23 AM  
Joined: 9/28/2005 Last visit: 7/6/2017 Posts: 2954 Rating: (225) 
I was wrong . You're right, the period is 10 sec. Then this is more possible . But maybe you don't need to create a table for all voltage values ? Maybe it is better to write some conversion routine that generates voltage output from sine value. For example sine goes from 100% to +100% then 100%=0V, 0%=5V and +100%=10V. 
Best regards, 

3/18/2009 12:36 PM  
Joined: 10/31/2005 Last visit: 7/15/2015 Posts: 2348 Rating: (233) 
Writing routine is generally easier. Supose you have OB35 with 10ms calling time. In OB35 you can chage value cyclically for 0 to 1000 (each call alters value by 1). I supose 0..10V signal. Then Output=27648/2 + //5V  basic level SIN( (value/1000) * 2 * pi) // on changing value from 0 to 999 this would change from 0 to 2pi //with 1000 samples. SIN would produce from 1 to 1 then *5 //increase amplitude from 1 ..1 to 5V .. 5V *27648/10 // to get code from volts 
Follow us on