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 - 2 analog inputs comparison

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

2 analog inputs comparison (by John)
Dear friends,

i would like to implement a 2 analog compare function with ldmicro to control a motor.

Left value reads A0 from arduino
and Right value read A1 from arduino.

If A0>A1 the motor must go Left and if A1>A0 the motor must go Right. If A0=A1 must stop.
The system compares values with a deadband of 10.

I build the system and works good but i like to do it with ldmicro.

Any help will be appreciated.
TIA
Sat Jul 28 2018, 18:33:25, download attachment 2018-07-29_012936.png
(no subject) (by Alex)
interesting, is there an example for 2 analog inputs? i have tried to do my own but... i donīt know, my pic freezes with 2 analog inputs and doesnīt send to my lcd the reading, i have tried to use cycle ON/OFF timer to read each adc input differently time but nothing happens
Sat Jul 28 2018, 21:52:26
(no subject) (by Alex)
ladder,
Sat Jul 28 2018, 22:02:52, download attachment Alex_adc_2_POT.ld
(no subject) (by MGP)
Alex, adc = 0 - 1023 and duty = 0 - 100% think again ;)
Sun Jul 29 2018, 01:59:26
(no subject) (by John)
The project i'm referring at is a LDR based solar tracker.
I need to control 2 arduino analog ports and other 2 as outputs for relay control.
I did that correctly with proteus and now i want to do it with ldmicro.

I would leave it there but i need PLC logic and ldmicro is perfect for it.

Also when i try to send the compiled flash .hex to avrdude, i get stk500v2 receive error and no flashing happens.

When i put the .ino file into arduino, it works great.

Any help will be appreciated.
TIA
Sun Jul 29 2018, 03:52:33
(no subject) (by MGP)
Here you have a basic comparator program with 2 adc's and hysteresis.

You will also need to add some timing to get a stable state of the motors or calculate the average analog value of a range of ADC values.

Btw. I'm not familiar with Arduino.
Sun Jul 29 2018, 05:14:36, download attachment Comparator.ld
(no subject) (by John)
It looks very promising for my project
I will check it very carefully.

Thank you!
Sun Jul 29 2018, 08:24:34
(no subject) (by Alex)
i changed, adc = 0 - 1023 and duty = 0 - 1023 , it stills the same
Sun Jul 29 2018, 11:09:27, download attachment Alex_adc_2_POT_v2.ld
(no subject) (by MGP)
From where do you get the configurationbits (2F8A)?
Sun Jul 29 2018, 12:04:56
(no subject) (by Alex)
Configuration bits from Mikro basic pro for pics, it enables lvp icsp programming
Sun Jul 29 2018, 12:27:13
(no subject) (by MGP)
You did someting wrong because 2Fxx does not exist!
Sun Jul 29 2018, 12:33:46
(no subject) (by Alex)
After all these writing lvp hex it was wrong..., i just took what mikro pic basic showed me by enabling lvp icsp, that's all i want to enabling lvp icsp for pic16f877a
Sun Jul 29 2018, 13:01:17
(no subject) (by MGP)
Then Mikro pic basic is wrong but I doubt this...

Try 3FBA which I made with OshonSoft.
Sun Jul 29 2018, 13:48:27
(no subject) (by Alex)
Sun Jul 29 2018, 16:33:25
(no subject) (by MGP)
Do you have leds connected at the programming pins (portB) ?
Sun Jul 29 2018, 18:08:15
(no subject) (by Alex)
no, 2 leds are connected in portC, RC1 and RC2, PWM out pins
Sun Jul 29 2018, 19:20:46, download attachment leds_connected_for_PWM.jpg
(no subject) (by Alex)
sorry i made a video mistake, simulation ldmicro and pick it 2 are right but the board shown is with 2F8A configuration bits

this is what a i get with 3FBA (see image plz):



the "number 16" shown in lcd is from previous hex file, it just keeps like that after writing hex with 2 analog inputs
Sun Jul 29 2018, 19:42:09, download attachment leds_connected_for_PWM.jpg
(no subject) (by Alex)
leds from RC1 and RC2 pins keep turned onafter writing hex, they both donīt do anything when using potentiometer.
Sun Jul 29 2018, 19:44:02
(no subject) (by MGP)
I can't follow anymore... and look at rung 5

cls+home takes some time ... and \xFE\x34 at the end what command is this?
Mon Jul 30 2018, 03:06:53
(no subject) (by Alex)
Orbital commands pdf says that it is for 16x2 lcd
Mon Jul 30 2018, 07:54:14
(no subject) (by MGP)
Do you have an original Orbital LCD display?
Mon Jul 30 2018, 08:51:11
(no subject) (by Alex)
Actually i don, t
Mon Jul 30 2018, 09:36:27
(no subject) (by MGP)
Sorry but I give it up, it looks more like chatting ...
Mon Jul 30 2018, 11:06:35
(no subject) (by Alex)
i think issue is about RC2 pin for pwm out, it tested a ladder program with pwm out pins, RC1 and RC2 (pic16f877a), using RC1 pin works ok , when changing to RC2 it doesnīt work, finally i changed back to RC1, works ok.

https://www.youtube.com/watch?v=r_aYFuKeu_c&feature=youtu.be
Mon Jul 30 2018, 22:22:14, download attachment Alex_adc_V2.ld
(no subject) (by Alex)
Tue Jul 31 2018, 15:50:00
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):