Prox / RFID
Ladder Logic
[interfacing] †
Tube Joints
Key Code From Photo
SolveSpace (3d CAD)
SketchFlat (2d CAD)
Resume / Consulting
Contact Me

LDmicro Forum - PWM problem in LDmicro

(you are viewing a thread; or go back to list of threads)

PWM problem in LDmicro (by Solt)

in ldmicro there is a problem with pwm output. Ldmicro is too slow for converting ADC to PWM. I'm right? I have the same problems with a 16f88 20MHz osc. PLC cyc.time 10ms, if I go below 10ms it restarts itself. if i go over 30ms to plc cyc.time pwm goes with interruptions with 32KHz PWM, if the freq. is 1,22KHz also with interruptions but less often. If I use without pwm, everything is good. I hope there will be a solution in the future for problems like this.
Fri Apr 24 2020, 02:10:03
(no subject) (by MGP)
You must reset the PWM frequency before changing the frequency otherwise or it will not work.
You also have a frequency limit how low you can go with a 20MHz crystal.
Fri Apr 24 2020, 02:33:50
(no subject) (by Solt)
The frequency limit is 1,222KHz to 1MHz with 20MHz crystal,frequency limitation is given by LDmicro. i using V. of LDmicro.
I use single frequency program.
I tried with different resolution 10bit, 8bit.with 8bit resolution it is much worse.
Fri Apr 24 2020, 03:23:34
(no subject) (by MGP)
Post the LD-file so we can see what is wrong.
Fri Apr 24 2020, 06:02:01
(no subject) (by Solt)
Here is the file
Fri Apr 24 2020, 15:47:20, download attachment cool_pwm_mod.ld
(no subject) (by Solt)
The output mosfet is a irf9540, the driver is vn0106n3
I must try with opto. TLP250 or 350.
I try later, same LD-file with Atmega8
Maybe it will work ADC to PWM
Fri Apr 24 2020, 17:19:12
(no subject) (by MGP)
This is not about the PWM freq. but duty-cycle!

I think it should work, I don't see any errors.

ADC, PWM and cycletime have nothing to do with each other and can work perfectly in any cycle time.
If you send the ADC value to the duty-cycle, the latter must be set to 10bit.

If the 16F88 resets, I think there is something wrong with the power supply or schematic.
Sat Apr 25 2020, 02:35:40
por Solt) (by Paulino)
Hello, you have RESET (RES) that have to be Reset by pulse (high francs or low francs) not direct since if you have direct resets they will always be reset since the res sends over the Stay, if you do the test with a direct reset and give March you will see that the lines in the simulator seem to be working but if you look at the program pins you will see that they are 0 not 1 (in ladder programming this has to be taken into account.

Hola Tienes RESET (RES) que tienen que ser Reset por pulso (Franco altos o Francos Bajos)no directos ya que si tienes reset directos siempre estarán reseteados ya que el res manda sobre el Estar, si haces la prueba con un reset directo y das marcha veras que las lineas en el simulador parecen ser que funcione pero si se pone vista en las patillas del programa veras que están en 0 no en 1 ( en la programacion en escalera esto se tiene que tener en cuenta.
Sat Apr 25 2020, 08:01:06
(no subject) (by MGP)
Btw. I have not looked at the program just the PWM problems and config words.
But as Paulino writes, you may also need to rethink your program.
Sat Apr 25 2020, 08:30:15
(no subject) (by Solt)
Hi Paulino,

The program works correctly, including (RES). My problem is why PWM can't work at 32KHz. It cannot work with variable ADC, only if it is set to a frequency between 1.2KHz and 4.5KHz.
At 32KHz it can work if the ADC is 1024 bits.
Sat Apr 25 2020, 15:40:11
(no subject) (by MGP)
I have tested your program in real with a 16F88 and it works fine.
I can select all the frequency's I want, from <1500Hz to >100kHz and the dutycycle from 0-1023.

Remember, the pullup resistors are ON !
Sun Apr 26 2020, 04:29:59
(no subject) (by Solt)
Problem rezolved.......do not buy mosfet from China!
:) After three china mosfet, i ordered genuine mosfet, and everithing works great. Now i using at 48KHz.

Thank you MGP for your time.
Thu Apr 30 2020, 05:26:27
(no subject) (by Paulino)
The Chinese are the sack man, I buy transistors and out of 100 they work 10%, these people work around the world. In the laboratories of the company Tecno Calubert S.L it is where the verification tests are made and the Chinese are over 70%, it does not work as expected.
Thu Apr 30 2020, 12:35:30
LD micro ultrasonico (by gabriel )
como se configura en ld micro el sensor ultra sonico ya probe de varias formas pero no puedo encender mis salidas a las distancias que quiero
Fri Nov 19 2021, 23:51:23
(no subject) (by Calubert)
Sat Nov 20 2021, 09:55:13
Post a reply to this comment:
Your Name:
Your Email:
(no HTML tags; use plain text, and hit Enter for a line break)
Attached file (if you want, 5 MB max):