!6F15324 PWM RC5 and RC3

43 views
Skip to first unread message

hans

unread,
Aug 23, 2022, 7:57:08 AM8/23/22
to jallib
Hello all.
I am looking for an example to use the 16F15324 for two PWM motor dirver outputs.
Is there any?
regards
Hans

Rob CJ

unread,
Aug 23, 2022, 1:10:00 PM8/23/22
to jal...@googlegroups.com
Hi Hans,

I did not see a sample file using two PWM's. I assume you can just include two PWM libraries and give it a try.

Note that for this specific PIC you can use PWM3, PWM4, PWM5 and PWM6 since for this PIC they start at 3.

I recently added libraries for PWM5 and PWM6 and sample programs for that.

As a test I of your challenge I combined the two pwm's from one of the sample files by just copying the lines of pwm5 and change them into pwm6 so the behaviour for both leds is the same, see attached file. 

The compiler finds it OK but you need to test if it works for you (I did not test this) 🙂.

Kind regards,

Rob




Van: jal...@googlegroups.com <jal...@googlegroups.com> namens hans <hanz...@zeelandnet.nl>
Verzonden: dinsdag 23 augustus 2022 13:57
Aan: jallib <jal...@googlegroups.com>
Onderwerp: [jallib] !6F15324 PWM RC5 and RC3
 
--
You received this message because you are subscribed to the Google Groups "jallib" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jallib+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jallib/5863d968-50c5-4e84-97d9-75ea6a9b41d0n%40googlegroups.com.
16f18323_pwm5_pwm6_led.jal

hans

unread,
Aug 24, 2022, 2:34:33 PM8/24/22
to jallib
hello Rob,,
Have tried  long time but many( 23) errors. To much for this old chap.
regards
Hans

Op dinsdag 23 augustus 2022 om 19:10:00 UTC+2 schreef rob...@hotmail.com:
16f15324_pwm_test3.jal

Rob CJ

unread,
Aug 25, 2022, 1:13:07 PM8/25/22
to jal...@googlegroups.com
Hi Hans,

You discovered a limitation in some of the PWM libraries. For newer PICs some things have changed.

I modified 3 libraries to get it compiling again using your program but did not test this, see attachement.

Can you include these libraries in the same directory as your main program, test it and see if it works?

I can test it later this weekend but if you have tested it and it works I can skip that. If all is OK I will upload them the Jallib.

Thanks.

Kind regards,

Rob


Verzonden: woensdag 24 augustus 2022 20:34
Aan: jallib <jal...@googlegroups.com>
Onderwerp: Re: [jallib] !6F15324 PWM RC5 and RC3
 
pwm_common.jal
pwm_pwm3.jal
pwm_pwm4.jal

hans

unread,
Aug 25, 2022, 2:55:40 PM8/25/22
to jallib
Hi Rob,
I put the file I showed yesterday in a separate folder. Add the three files you posted. When I compile now I don't get any errors anymore. I can see that he uses the common, but I don't know which of the other two. I'm going to test the case tomorrow to see if it works.
thanks again
regards
Hans

Op donderdag 25 augustus 2022 om 19:13:07 UTC+2 schreef rob...@hotmail.com:

Rob CJ

unread,
Aug 25, 2022, 4:17:24 PM8/25/22
to jal...@googlegroups.com
Hi Hans,

The compiler first looks for the include files in your current directory of the main program. If it does not find it there, it will look in your jallib\lib directory.

In this way you can easily 'overrule' and existing JAL library by having a local copy. Having local copies is not recommended since you will not get any updates when Jallib is updated but for testing purposes it is OK>

As said, if it works I will add it to Jallib so that it will be present in one of the new bee-packages. 

If you then install a new bee package you should remove the local copies since if updates are done later, you want to use the updates from Jallib and not your local copy.

Good luck with testing.

Kind regards,

Rob


Verzonden: donderdag 25 augustus 2022 20:55

hans

unread,
Aug 25, 2022, 4:20:49 PM8/25/22
to jallib
Hi Rob,
Hi Rob,
compiled and loaded with Pckit. Okay. Put on test board, leds on C3 and C5. 33K on mclr. LVP off. Both leds  go on and off but no light variation.
attached used program

Op donderdag 25 augustus 2022 om 20:55:40 UTC+2 schreef hans:
16f15324_pwm_test3.jal

hans

unread,
Aug 26, 2022, 3:11:37 AM8/26/22
to jallib
Hi Rob
morning test. Suddenly doesn't work anymore. Scoop doesn't give a signal either.
  Blink a led on both outputs C3 and C5 tested and freq to 16 (oB101) all works well.

Op donderdag 25 augustus 2022 om 22:20:49 UTC+2 schreef hans:

Rob CJ

unread,
Aug 27, 2022, 4:56:37 AM8/27/22
to jal...@googlegroups.com
Hi Hans,

I fixed the problem. There where actually two problems:
  1. The PIC you are using has 3 prescaler bits instead of 2. The frequency would then not be correct.
  2. The PIC you are using has a separate clock register for Timer 2. The default of that register is that it does not use Fosc/4 as input and because of that Timer 2 was not running.
Attached the update of the files. Please put them in your directory for testing. I also removed the deprecated functions from pwm3.jal and pwm4.jal since sufficient time has passed for JAL users not to use deprecated functions. It makes the code cleaner.

It works with your program but please remove the statement CCP1CON = TRUE from your program. It is not needed. I attached the version of your program again but changed the clock frequency to 32 MHz. The program also works with 4 MHz as in your original program. I also changed the program a bit. When the brightness of one LED increases, the other one decreases and the other way around. I changed it so that you can see that both LEDs work independently.

Let me know if it also works for you. If so I will upload the changed files to Jallib.

Thanks.

Kind regards,

Rob


Verzonden: vrijdag 26 augustus 2022 09:11
16f15324_pwm_test3.jal
pwm_common.jal
pwm_pwm3.jal
pwm_pwm4.jal

hans

unread,
Aug 27, 2022, 6:20:56 AM8/27/22
to jallib
Hi Rob,
It works great.. Thanks again and again.
regards
Hans

Op zaterdag 27 augustus 2022 om 10:56:37 UTC+2 schreef rob...@hotmail.com:

Rob CJ

unread,
Aug 27, 2022, 7:34:19 AM8/27/22
to jal...@googlegroups.com
Hi Hans,

You're welcome. I uploaded the files to GitHub so they will be part of the new bee-package. 

You can do 3 things:
  1. Do nothing 🙂 keep it as it is (not recommende)
  2. Download and install the new bee-package when it is available or
  3. Copy the files I sent you to the jallib\lib directory on your computer. You can then remove them from the directory where your main program is. In this way you are sure the files are also used when you develop a new program.
Kind regards,

Rob


Verzonden: zaterdag 27 augustus 2022 12:20
Reply all
Reply to author
Forward
0 new messages