GATING PWM output - for a number of "pulses"..??

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 7.

Moderator: Benj

Post Reply
DCW
Posts: 64
Joined: Mon Sep 28, 2015 8:19 pm
Has thanked: 14 times
Been thanked: 10 times
Contact:

GATING PWM output - for a number of "pulses"..??

Post by DCW »

Hello forum.. okay so you pull down a processor .. 16F1824 .. you configure it with the PWM component.. you get it working.. it's outputting 50% duty cycle waveform on Pin5.. RC5.. of that chip..
All good and fine.. So now I want to gate that PWM signal on.. and off.. HOW DO I DO THIS PLEASE.??
BTW - the pulse length is 600 usec.. MARK, and 600 usec SPACE... So I need - 12 MARK pulses and 12 SPACE pulses.. so that if I use say RA0 as an interrupt - IOC PORTA.. then when tactile switch presses up to VDD.. then RA0 triggers the interrupt macro.. and well - you could do your thing there... your routine will count up to maybe 24.. up and down's .. giving 12 MARK and 12 SPACE outputs...

So I thought about.. this for a while.. then started to realize that we have to switch into C code.. unless someone knows a FC way to do it..!!

What thoughts - please.??

Regards
DCW

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: GATING PWM output - for a number of "pulses"..??

Post by Benj »

Hello,

How about something like this.

The PWM output will need to be connected across to pin A0 and the trigger switch connected to A1.
Example.fcfx
(12.21 KiB) Downloaded 295 times

DCW
Posts: 64
Joined: Mon Sep 28, 2015 8:19 pm
Has thanked: 14 times
Been thanked: 10 times
Contact:

Re: GATING PWM output - for a number of "pulses"..??

Post by DCW »

Hello Ben .... GEE thanks for that...
ONCE again... you have proved yourself.. to be an OFFICER and a GENTLEMAN of the FLOWCODE.. a REAL SIR.!!

thanks very much Ben Sir.!!.. you have solved a fairly huge problem again.. now I can get along with the project...

Kindest Regards
DCW ...

DCW
Posts: 64
Joined: Mon Sep 28, 2015 8:19 pm
Has thanked: 14 times
Been thanked: 10 times
Contact:

Re: GATING PWM output - for a number of "pulses"..??

Post by DCW »

hello forum guys... okay so I have attached a small FC7 created flowchart.. which sposed to help in creating some pulses, via the PWM logic in the chip. I using a 16F1936, with internal frequency of 16 mHz. So then the program creates first a series of 12 pulses.. with 50% duty cycle. The period of the pulses is.. 1200 usec. So at 50% .. a MARK pulse is at 600 usec width, whilst the SPACE pulse is at 600 usec width. After this is complete.. the program carries on with the next stage.. after a 4 ms delay. The next stage, has to create a 32 bit pulse train, where the MARK/SPACE ratio of the pulses varies from say 400 usec = MARK pulse, to 800 usec = SPACE pulse. So the program does loop and create the 32 pulses.. but when the pulses are generated, there is a macro called, which reads a 'digit' from an array file..(compiled into the C-code)..LUT..(LookUp Table).. So as the macro reads the array.. the values are 'index'ed off .. with index variable incrementing, so that the variable 'digit' has the value of the 'index'ed read from the LUT array.. So the first 'digit' should be.. a '0' at 'index' position 0.. and then the second, third, fourth, and fifth 'digit' should be '1' values with incrementing 'index' value, accordingly.. So this happens.. okay..(or is it.??).. When we get to the 6th place in the array.. (load the FC7 flowcode file.. go and look at the array in the LUT.. component...), we should be having a '0' in the 'digit' variable.. which sposed to be sorted out to be a wide pulse.. so the PWM1 component.. will then output a pulse of 800 usec width.. BUT IT's NOT..!
So anyone maybe interested.. in helping me find my SIMPLY STUPID fault... in the FC7 file..
Okay forum guys... anyone may help.. please... thanks.. folks..
If you look at the photo.. of the waveforms.. you can clearly see the different widths of the pulses... The first 12 pulses are there on the left side.. not all shown.. but the 32 bit pulse train sposed to be varying in widths.. of each pulse depending on the value of either 0, or 1 read from the array file.. of the LUT..

Thanks very much..
Kindest Regards
DCW..
Attachments
PW waveform output of the flowchart-image2.JPG
PW waveform output of the flowchart-image2.JPG (112.3 KiB) Viewed 3851 times
PW-generator-for testing 1936-FLowcode7.fcfx
simple flowcode 7 file
(21.62 KiB) Downloaded 254 times

Post Reply