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 - 16F887 internal oscillator

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

16F887 internal oscillator (by smorc)
hello, I want to use internal crystal with 16f887 processor. stock setting 0x16FF3F84
I changed with 0x3EFF23E4 but I think I have a mistake. I will be glad if you help.
Thu Oct 20 2022, 14:13:31
(no subject) (by MGP)
For the 16F886 I use 0x3FFF23D4 as configbits

And the first rung in your program is for 8Mhz

|-----OSR-----mov #0x8F 0xF0 -----|

See also the jpeg attached
Thu Oct 20 2022, 15:52:14, download attachment Snap240.jpg
(no subject) (by smorc)
Dear MGP, thank you very much for this information.
I am using your crystal settings as they are. And I started getting results.

16f887 I'm dealing with 2 pwm signals
Fri Oct 21 2022, 08:36:55
potentiometer (by smorc)
I need a suggestion. if i want to use potentiometer instead of button.

I got it with the potentiometer. value 1024. unknown. If I want to divide by max and min limit.

This value will be obtained with the adc voltage read, sometimes 50, sometimes 55, sometimes 60 or more different numbers. Can the number 1024 always increase or decrease the difference in the meantime?

Since the number of max and min values ​​is not clear, I could not reason with the division operation.

--The max value will be between 0-1024. eg it was 748.

--The min value will be between 0-1024. eg it was 617.
I want the number 131 to be 0 when the potentiometer is 0. When the potentiometer is 1024, I want it to give the number 131. is it possible.

I could not reason because the max and min value can always take different values ​​between 0 and 1024.

I would be grateful for any suggestions.
Sat Oct 22 2022, 09:24:15
(no subject) (by MGP)
I've read it 10 times now and I still don't understand what you're trying to say.
Sat Oct 22 2022, 13:12:25
(no subject) (by smorc)
I use google translate, that may be why.
I am controlling an integrated with volts. With 10 bit pwm amplitude control.
The duty cycle value starts from 0, the max value is 45, which I need, sometimes it is a different value.
I want the potentiometer value to be equal to 1024 duty cycle 45 value.
Sat Oct 22 2022, 13:23:40
(no subject) (by smorc)
In the program, the duty cycle value automatically increases. When the voltage determined to read the adc comes, the duty cycle stops. and the value where it stops, for example 47 I want to be my max dutycycle limit. Then I want to increase and decrease the duty cycle value with a potentiometer up to this max limit. My problem is that I have to make sure that the potentiometer 1024 value is equal to my duty cycle value. the issue is this value changes according to the setting
Sat Oct 22 2022, 13:32:06
(no subject) (by MGP)
For conversions I always use the PWL instruction, very easy.

The X-axis is the analog readout from 0 -1024.
The Y-axis is the pwm value, from 0 - 46%

Because LDmicro works with integers, the 0 - 1024 is too large and you have to put a value in the middle.

X axis 0 = Y axis 0 pwm
X-axis 512 (middle) = Y-axis 23% pwm
X axis 1024 = Y axis 46%

So on all values of the adc 0-1024 you get back a value of 0 - 46 calculated by LDmicro.

See example and take a good look at it because it is generally usable in conversions, I always use that.

Have fun with the new instruction ;)
Sat Oct 22 2022, 14:00:48, download attachment 16F886_adc_pwm.ld
(no subject) (by MGP)
I made an small error in the PWL instruction y1 must be 23 (half of 46%) not 22.
Sat Oct 22 2022, 14:07:38
(no subject) (by smorc)
Thank you very much, very useful.

I changed the value of 22 to 23.

y1 and y2 determine the max values. I do not know this value. this
The value is determined when the inverter runs, when the required current comes in, and when the dutycycle stops. Do I have a chance to assign that value to y1?
Sat Oct 22 2022, 14:21:09
(no subject) (by smorc)

this is something i've been looking for, it's worth gold. The only problem is that the value that should be in y1 and y2 is not known beforehand.
This value is found when the program runs the calibration.
Sat Oct 22 2022, 14:26:14
(no subject) (by MGP)
You can change all the nummers as you want.
If you want a pwm from 30 to 70 on adc of 0 -1024 then Y0 = 30 and Y2 = 70 (for 2 points)

Play with it, draw an XY graph and draw the lines.
Sat Oct 22 2022, 15:57:18, download attachment Snap243.jpg
(no subject) (by MGP)
ow, now I kinda understand your problem but it's a tricky question if you don't really know how to get started.
Sat Oct 22 2022, 16:01:49
(no subject) (by smorc)
Yes, I am in trouble. I am using 2 different pwms. pwm outputs are made of dac.

pwm1 determines the inverter low current limit.

The pwm2 inverter determines how much power it should have.


Therefore, the initial value of pwm2 duty cycle is 0.

but the value of the max final power is calculated later.


I need to write the calculated value as a duty cycle high value. and then I need to move the potentiometer from 0 to max.
Sun Oct 23 2022, 01:50:16
(no subject) (by MGP)
Too complicated for an outsider, programming predictions is difficult :)
Sun Oct 23 2022, 03:02:43
(no subject) (by smorc)

yes, my luck usually never happens :)))
there are ways to do it but it will take up a lot of space.

and the resolution will be less.


The duty value increasing from 0 to (eg 84) is actually unknown and variable. Multiply by 100. by dividing by 10.


I plan to control it with a potentiometer, of course, I will have very few steps, unfortunately.

in your sample program. If we could enter a value later on the y-axis. it would be great.


great solution for previously known values ​​pwl
Sun Oct 23 2022, 03:31:33
(no subject) (by MGP)
It has nothing to do with luck but with programming knowledge ;)
Sun Oct 23 2022, 09:10:45
(no subject) (by smorc)
yes i tried many things but it didn't work :P I'm attaching the program here, I'd appreciate it if you could take a look.

what I want to do in the program. When the up button is pressed, the duty cycle increases. stops at the desired location.

then, if the potentiometer input exceeds 50, -10 should be subtracted. If the potentiometer becomes 0 again, it should return to the old duty cycle value.

When the potentiometer is activated, the duty cycle value is constantly falling, I could not find a solution to this.

I would be grateful for any suggestions
Sun Oct 23 2022, 14:50:22, download attachment SG_OTAMATİK.ld
(no subject) (by smorc)
new file is here
Sun Oct 23 2022, 14:52:17, download attachment SG_OTAMATıK.ld
(no subject) (by MGP)
You have to be careful with the persist instruction, the eeprom in the controller can only be overwritten 100,000 times, therefore LDmicro has a protection and it only overwrites the value if it is different from the previous one.

But with you, the variable changes every millisecond (TCY500µs) and so your controller could fail after 10 hours of operation.

The rest is for tomorrow.
Sun Oct 23 2022, 16:06:01
(no subject) (by smorc)
If I add a button for recording, it will have a longer life then? this is an important detail

What I want to do in the program is simple but difficult to create. pwm starts, inverter frequency changes according to increasing voltage.

When the starting frequency is found, the frequency increase stops. and I want to increase it up to max power with potentiometer.

The place where I am stuck and the duty value, which is the starting point, should stay in the memory and I have to add and subtract from it.

In case of overcurrent, I still need to reduce the duty value. should remain in memory at the old value.

I tried a lot of different things over the weekend and it didn't work. While the initial value of duty remains in memory, the second operations are difficult.

I believe you will have a suggestion, Mr. MGP I can tell this much with GOOGLE TRANSLATE sorry
Mon Oct 24 2022, 00:14:20
(no subject) (by smorc)
I found a way, and the recording life is long. The ever-increasing value is not recorded on the empro. thus. I will also be able to reduce the power by subtracting the increasing max duty cycle value. I think it will take up a bit of space but it's done. :)

I think the right thing was done in the recording case.
Mon Oct 24 2022, 14:01:50, download attachment OTO+POTANS+EKLE.ld
(no subject) (by MGP)
Sorry but I didn't have time yesterday.
I still don't understand what you want and frankly your program looks a bit confused.

-Rung 9 & 10 do nothing because rung 8 determines everything, you can even delete them.

-The persist instruction is not correct yet, 'duty-cycle' is overwritten with every change, just calculate (max 100000 times per chip)

- duty-cycle & duty-cycle1 pwm have the same output pin and name, rung 3&4
Tue Oct 25 2022, 03:11:13
(no subject) (by MGP)
Maybe I was a little too quick with my conclusions regarding rung8, 9 & 10.

At AS>50, 8 is subtracted.
At AS>100, 16 is subtracted.
At AS>150, 24 is subtracted from Duty-cycle1.

If that's the intent then it's correct, sorry
Tue Oct 25 2022, 04:51:11
(no subject) (by smorc)
np.. I'm almost done. Thank you very much for your help and Everything seems fine for now.
Tue Oct 25 2022, 09:41:30
(no subject) (by MGP)
Good luck with your project.
Tue Oct 25 2022, 13:26:10
(no subject) (by smorc)
The trials have been very successful. but the cpu sometimes hangs on the first boot. I need to reset the mclr pin.
I guess I need to put a wait at the beginning of the program.

What is the best solution for this?

There are 3 registration processes, I have a 22% occupancy rate.


We used to wait 1000 ms in basic, would it work if I use the same logic for the registers to sit in place?
Thu Oct 27 2022, 14:02:33
(no subject) (by MGP)
You need a 33K resistor to the +5V at the MCRL pin and the rung that determines at which clock frequency you work, otherwise you get this error.
Fri Oct 28 2022, 07:02:45, download attachment Snap240.jpg
(no subject) (by smorc)

I am using your 8 MHZ settings as they are.

Connected to 10k +5volt on mclr pin

I think I need to connect 33k gnd here.
Fri Oct 28 2022, 08:51:21, download attachment R1.png
(no subject) (by smorc)
here is my schematic.. If it's better if I use crystal, I can wear it.
Fri Oct 28 2022, 08:54:23, download attachment R2.png
(no subject) (by MGP)
10K is ok.

Post your diagram if you have one, I don't think it's software but hardware.

After many hundreds of programs I never had any problems with the software from LDmicro, if there were problems it was always the hardware.
Fri Oct 28 2022, 09:01:27
(no subject) (by smorc)
I am currently working on a portable. and somewhat disorganized. I'm checking integrated with lm358, it's a possible problem from there.

For now, the lm358 may be giving feedback when the power is cut, I'm trying to detect it.
I will also add a resistor for fast discharge for 5volt supply.
thank you
Fri Oct 28 2022, 09:33:20
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):