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

LDmicro Forum - Poor understanding of counter fundamentals

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

Poor understanding of counter fundamentals (by Ziggy)
OK ...
I am ashamed to say it but ...

Please see the attached file

The idea is that there is a sensor input which instigates a change in PWM duty cycle.

Duty cycle varies between 50 and 0.

Upon starting the ladder initialises warning light and sound

When the sensor button is pressed the light keeps on working while the sound is extinguished based on a combination of three links which short PD5 PD6 and PD7 to ground respectively.

If the sensor button is depressed for longer than 3 counts an output pin latches.

Everything simulates nicely I think. But when the hex file is loaded into the micro ( AtMega8) the three links do not have any influence on the timing of PWM signal.

Any comments welcome. I have obviously missed some finer point and the outcome is garbage
Mon Dec 12 2016, 01:01:20, download attachment headache.ld
(no subject) (by Ziggy)
It seems the three shorting links are not recognised/decoded correctly
Mon Dec 12 2016, 04:16:11
(no subject) (by MGP)
I dont understand what you mean, neither how the program works.
Can you tell us what the input do..

Xon = .............
Xtwo= ............
..
Mon Dec 12 2016, 11:00:58
(no subject) (by Ziggy)
Xone Xtwo and Xthree are inputs which should allow different counters/preloads to be selected ( rungs 20 to 27)

Xon is the sensor button which causes the PWM output to run with 0 PWM coefficient for the duration of selected counter final count ( rung 18).

By presetting Xone etc prior to commencement of simulation, different end counts are to be selected.
Mon Dec 12 2016, 12:56:24
(no subject) (by Ziggy)
The real question is

how to read the status of three input pins

and set the up counter end of count based on the configuration of the three bits

111 -> 45
110 -> 40
101 -> 35
100 -> 30
011 -> 25
010 -> 20
001 -> 15
000 -> 10
Mon Dec 12 2016, 17:30:30
(no subject) (by Ihor Nehrutsa)
Used 'Look-Up Table' element
Mon Dec 12 2016, 19:03:40, download attachment h1.ld
(no subject) (by Ihor Nehrutsa)
Fragment of CHANGES.txt

...
== Release 3.5.0 experimental pre-release

* Modified:
Max value in Element COUNTER and CIRCULAR COUNTER
was defined as
int max;
now redefined as
char max[MAX_NAME_LEN];

Now you can use variable as argument of a COUNTER.
It allow to create more sophisticated algorithms in LD.
...
Mon Dec 12 2016, 19:10:43
(no subject) (by Ziggy)
Hello Ihor,

Thanks for Your advice.
Sadly just like my original efforts it simulates perfectly however when hex is loaded into the micro the selection of counter preloads does not happen.
I have written a small program to check the pins are corectly identified and do in fact respond.

I shall try to mock it up using another processor chip ( 28 pin DIP ) to check the hardware more thoroughly.

Will come back to cry some more I am sure.
Tue Dec 13 2016, 03:53:00
(no subject) (by Ihor Nehrutsa)
I will try simulate in Proteus.
Tue Dec 13 2016, 04:00:13
(no subject) (by Ziggy)
This is the ladder diagram I have tried to run on both package styles of ATmega8.
The 32 pin device was on a PCB, the 28pin device on STK500 board.

Accounting for STK500 inverted switch and LED functioning no difference and no joy.

I can only conclude I must be making some cardinal mistake in my application of LDmicro.
Tue Dec 13 2016, 04:50:55
(no subject) (by Ziggy)
Apologies... did not attach the file
Tue Dec 13 2016, 04:51:54, download attachment headache4.ld
(no subject) (by Ihor Nehrutsa)
Please show the technical specification, algorithm of work.
I dont understand what you mean.
Wed Dec 14 2016, 04:46:44
(no subject) (by Ihor Nehrutsa)
Are the Xone, Xtwo, Xthree buttons 'Normal open' contacts?
Is Xsensor 'Normal closed' contact?

Pull up resistors
https://github.com/LDmicro/LDmicro/wiki/Pull-up-resistors
Wed Dec 14 2016, 06:44:55
(no subject) (by Ihor Nehrutsa)
You can delete elements after an 'OPEN-Circuit' element.
Wed Dec 14 2016, 07:29:23, download attachment headache4_1.ld
Post a reply to this comment:
Your Name:
Your Email:
Subject:
(no HTML tags; use plain text, and hit Enter for a line break)
Attached file (if you want, 5 MB max):