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 - Confused

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

Confused (by Tom J)
Had some issues programming a pretty big program onto a PIC16F877 and decided to take a step back and do something simpler so I wrote a fairly simple ladder and compiled it for ATMEGA328.

This still doesn't do anything but pull Y1_2 high at startup and hold it there. Naturally I attribute my failure to some rookie mistake but I've read through the datasheet, numerous forum posts and the programmer user guide to no avail.

If one of you guys sees something I don't please enlighten me. The only thing I see now is some confusion I had in the datasheet where I now believe the INT RC is actually 1MHZ and I have it as 8MHZ in the program so I'll rectify that and try again with a fresh MCU tonight but I don't want to jeopardize one if there's something else I missed.
--------------------------------------------------
LDMicro 4.3.8

Compiled on Linux, Compiled again on Windows7 tried both HEX files

ATMEGA328 (Actually says ATMEGA328 U on chip)

GQ-3X programmer (I've used for EEPROMs at work so it works)

ISP - checked all 5 connections a dozen times, using a brand new breadboard, new jumpers. 7805 on breadboard.

RESET - programmed and tested with it pulled high through a 1K resistor and without it pulled high.

5V on pins 7& 20
GND on pins 8 & 22

---------------------------------------------------

PaddleShifter is a ladder to set a state on 2 outputs (Y1_2 & Y3_4)
These outputs are the parity for shift solenoids in a GM 4000 series transmission but naturally I'm just testing with a couple of LEDs, not the actual supporting circuit.

Inputs: Xup & Xdown are moving up or down through the gears.
Inputs: XFirst, XSecond, XThird & XFourth put Y1_2 & Y3_4 directly into the states for that gear.

--------------------------------------------------

Any criticism or advice appreciated, thanks in advance...
Sun Mar 11 2018, 18:08:30, download attachment PaddleShifterATMEGA328.ld
(no subject) (by Tom J)
Oh, and GQ shows a correct device ID of 1E9514,Correct Manufacturer, but no Type or Revision
Sun Mar 11 2018, 18:14:46
(no subject) (by Tom J)
Another curiosity that the outputs are high in first as they should be but the states are "0" down below... re-writing the ladder I can get them to work if that rung is last but then other gears are incorrect states.
Sun Mar 11 2018, 19:30:41
(no subject) (by MGP)
Give your variables a name, not Cnew for a CTR counter and Cnew for a CTC counter, do not add or manipulate those counters by adding a 1.

While you push a button, every cycletime you add 1 to the variables until you stop pushing the button, also use an OSR after the buttons.

It's not the controller it's the programmer ;-)
Mon Mar 12 2018, 03:04:38
(no subject) (by MGP)
I have changed your program a bit. Good luck.
Mon Mar 12 2018, 04:25:13, download attachment PaddleShifterATMEGA328_V2.ld
(no subject) (by Tom J)
Thank you MGP! Can you see a reason why the state is 0 on both outputs in first? I noticed the 2 gears at once thing before, it favors the higher gear which isn't so bad.
I may lock out the other inputs while one input is enabled later but for now this was just a simple program to get started IRL.
Mon Mar 12 2018, 20:23:22
(no subject) (by MGP)
This is because the variable starts with the value 0.
Therefore you need to set the gear variable to 1 at the start of the program.

See the attached file rung 0001
Tue Mar 13 2018, 03:14:17, download attachment PaddleShifterATMEGA328_V3.ld
(no subject) (by MGP)
Sorry, program V2 is OK.

Maybe I dont understand your question, everyting works fine here.
Schematic...?
Tue Mar 13 2018, 03:38:10
PaddleShifterATMEGA328.ld (by Para Ton)
Hola Ton prueba a las salidas (Y) solo una vez activarlas usa reles interno, como sabemos muchos PLC solo quieren una salida única por variante, las entradas las puedes repetir cuantas veces desees, pero las salidas solo una. (prueba y funcionara como lo deseas).
Tue Mar 13 2018, 05:43:06
(no subject) (by Tom J)
This is what I meant, the outputs are clearly colored red in the simulation but the states are both 0, they should both be 1.
Maybe it's a flaw on my computer but it's an odd one.
Tue Mar 13 2018, 19:20:02, download attachment Screenshot from 2018-03-13 19-08-21.png
(no subject) (by MGP)
Now I see the error, you can't have two rungs with the same relay because the status of the relay takes the value of the last rung.
Tue Mar 13 2018, 19:33:53, download attachment Snap328.jpg
(no subject) (by MGP)
This should be better.
Tue Mar 13 2018, 19:56:03, download attachment PaddleShifterATMEGA328_V4.ld
(no subject) (by Tom J)
That is indeed better, thank you.

Strange because I got away with the same relay in several rungs on my sequencer program in the simulation, I suppose I should re-write it so it doesn't glitch.

This version has some unnecessary stuff to auto run it, otherwise it requires many cycles of the inputs to make it work in a manner that runs the status LEDs.
Tue Mar 13 2018, 20:23:29, download attachment SequencerStart6_Autorun_PICF876A.ld
(no subject) (by Tom J)
Another dumb rookie question, say I have PIC16F877A, not PIC16F877 does it matter?

I've noticed with the PIC12C508 I can use PIC12C508A, PIC12F508, PIC12C509, PIC12C509A, PIC12F508 with the same HEX files. I've bought whatever I could get the best deal on for years with no repercussion.

Just don't know if the PIC16 is as forgiving...
Tue Mar 13 2018, 21:55:14
(no subject) (by MGP)
Yes, you can use the 16F877a without problems, which I also use regularly.

The other pic's 12Fxx not, because they are not in the menu list.

You can use the relay 2x if you know what you are doing but for now it is better not.

You can shorten programs if you have more experience, with time you will also handle it differently.
Wed Mar 14 2018, 03:33:00
(no subject) (by Tom J)
Still having problems here. I use a little JDM at work with the PIC12s that I've been using for years and a GQ-3X that I've been using for EEPROMs for years.

The GQ-3X is what I've been trying to use with the programs I've written in LdMicro using ISP to no avail.

Yesterday I ordered a MiniPRO TL866CS. I wanted a TL866II Plus but ordered incorrectly because an Ebay seller had a misleading title. Oh well, I get angry when buyers don't read my listings thoroughly and despite the misleading title I did fail to read the full description so I'll be getting a CS.

The GQ-3X still does in circuit programming so once I'm a little more experienced with it I should still be able to do in-circuit programming with the GQ and the CS still does all the MCUs I want to work with in it's 40 pin ZIF.

I just didn't want you guys to think I gave up after all your help, once the programmer from this decade arrives I'll be back on board later this week.

I'm still convinced my problems are centered around settings so in the mean time I'll be reading everything I can.
Sun Mar 25 2018, 21:39:24
(no subject) (by Tom J.)
I don't get it, had trouble with the ATMega and couldn't get it to do anything so I switched gears and re-compiled for a PIC16F628, programmed it to a PIC16F628A with the new MiniPRO.

If I set the fuses to INTRC with CLKOUT I can get a steady clock on the output (pin 15) so it has a clock (so long as I pull MCLR high).

All of the inputs go immediately high. The output on RB6 (pin 12) goes high, RB5 (pin 13) remains low.

I tried pulling inputs all down with 10K resistors and then pulling them high to input, I tried leaving them high and cycling them low as inputs.
Nothing works, any thoughts?
Sat Mar 31 2018, 03:52:36, download attachment PaddleShifter628_4mhz.hex
(no subject) (by MGP)
Upload the LD File not the hex file..
Sat Mar 31 2018, 03:56:05
(no subject) (by Tom J.)
I see the logic in that........
Sorry, it's been a long fruitless night.
Sat Mar 31 2018, 04:10:44, download attachment PaddleShifter628_4mhz.ld
(no subject) (by MGP)
The MCLR needs a resitor of 10K to the +5V, when pull down the controller resets.

PortB has standaard internal pullup resitors, so you must connect the buttons to the GND and invert the inputs, no other resistors are needed.

It should work.

Attached, your program with inverted inputs.
Sat Mar 31 2018, 05:11:57, download attachment PaddleShifter628_4mhz_V2.ld
(no subject) (by Tom J.)
That did it! Thank you MGP!
Sun Apr 1 2018, 14:21:39
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):