Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 16:38 05 May 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : pwm query

Author Message
oldtimer
Newbie

Joined: 02/12/2016
Location: Australia
Posts: 18
Posted: 07:40pm 23 Apr 2017
Copy link to clipboard 
Print this post

Hi All -
could anyone tell me how to make the PWM command a permanent fixture when running and editing a program - at present - running an explore 64 with an Silicon chip backpack - I have to rewrite the PWM 2 etc command after every change to see the result of editing or inserting 1 line of code- is there any way of making the line PWM 2,100,90 a permanent thing - and having the backlight on at all times

another small query - why is no pin number needed for this command - does PWM 2 default to pin 52 (on the 64 pin chip) unless another pin is specified - hoping someone can clarify

many thanks

oldtimer
 
panky

Guru

Joined: 02/10/2012
Location: Australia
Posts: 1098
Posted: 07:59pm 23 Apr 2017
Copy link to clipboard 
Print this post

@oldtimer

Have a look in the manual (page 45 in my 5.2 version) under the heading MM.STARTUP
- that should do what you need.

The Explore 64 Sil Chip Backpack has pin 53 of the PIC directly driving the LED input of the ILI9341 display and uses PWM channel 2A. As PWM2B is not used (used as SPI2 In from the ILI9341). 1000 if the frequency and the last figure is the duty cycle ie. brightness.

Cheers,
Doug.

... almost all of the Maximites, the MicromMites, the MM Extremes, the ArmMites, the PicoMite and loving it!
 
WhiteWizzard
Guru

Joined: 05/04/2013
Location: United Kingdom
Posts: 2794
Posted: 08:33pm 23 Apr 2017
Copy link to clipboard 
Print this post

@oldtimer,

I know what you mean - it is annoying.

Doug's suggestion isn't quite what you require as I believe that will only set it at power-up.

IF you are purely editing and then re-running your program then obviously make sure you include your PWM ... command near the start of your code to ensure the backlight is switched on - that way you will see the affect of any new codelines added.

However, whenever you EDIT a program, the firmware will 'reset' all I/Os to obtain as much memory as possible for the EDITor's features (that is my understanding from what Geoff has explained). This means that IF you are wanting to type a 'TFT/graphical' command at the Command Prompt after EDITing a program then you will have to type the PWM.... command first.

An alternative hardware fix I used in the past (on a different module) was to have a pull-up resistor on the 'input' to the driving transistor that controls the backlight pin. So rather than a 0v (or floating) output leaving the BackLight off, the Pull-Up 'forced' it on. Then once code was working I removed the pull-up.


WW Edited by WhiteWizzard 2017-04-25
For everything Micromite visit micromite.org

Direct Email: whitewizzard@micromite.o
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9066
Posted: 09:00pm 23 Apr 2017
Copy link to clipboard 
Print this post

I agree with WW. I believe he is correct, unfortunately, in that whenever you invoke the editor, this will reset all I/O pins, and wipe all currently assigned memory.

C'est La Vie....

I had a similar problem when I was using an I/O pin to drive a relay that enabled a network module for remote access. If you entered the editor as part of your remote-access, the pin controlling the relay switching power to the network module dropped off, and you lost the remote connection.

In your specific case, I don't think there is much you can do about this. If this was a mission critical PWM that you HAVE to have running all the time, then I would suggest using a 2nd 28-pin MM chip just to run the PWM, and control THAT from your main MM chip. That way, you can enter the editor all you like in the main MM, and the slave MM will keep driving the PWM.

Just an idea.
Smoke makes things work. When the smoke gets out, it stops!
 
oldtimer
Newbie

Joined: 02/12/2016
Location: Australia
Posts: 18
Posted: 09:36pm 23 Apr 2017
Copy link to clipboard 
Print this post

Many thanks - Panky,WW and grogster - as quick fix - Ill look at entering it in first lines of new code - long term I might go back to the 28 pin fix of just using the 5 volt line and pot to adjust - sometimes simple is better - and allows more time for frustration in other areas !!
regards
oldtimer
 
WhiteWizzard
Guru

Joined: 05/04/2013
Location: United Kingdom
Posts: 2794
Posted: 10:08pm 23 Apr 2017
Copy link to clipboard 
Print this post

If you are using the BackPack as featured in SC Nov 16, then take a quick look at the schematic on Page 68.

On Pin 53, there is a 10K pull-down (on the Gate of Q2 - 2N7002). IF you are able to solder SMDs, then I would recommend you remove it and 'convert it' to a pull-up. This will mean the BackLight is 'ON' by default, and you will then need to issue a PWM command to switch it OFF (if you ever need to).

Otherwise - just isolate the LED pin on your TFT (14 way connector) and link this to +v (or a POT divider like you mention).

Let us know what you end up doing . . . .

WW


For everything Micromite visit micromite.org

Direct Email: whitewizzard@micromite.o
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8592
Posted: 11:03pm 23 Apr 2017
Copy link to clipboard 
Print this post

Here is a solution (MM+ only)

Store this CFunction and MM.Startup in the library. This will automatically keep the backlight on at all times and allow the intensity to be varied whenever you want. Note that you can use any pin for the backlight. Duty cycle is 1 to 99, PWM frequency is 500Hz.


sub mm.startup
PWMBacklight 53,50 ' pin number, duty cycle
end sub
CSub PWMBacklight
00000025
'T5Int
3C029D00 8C42008C 8C43000C 54600005 3C029D00 8C430008 8C420004 AC620000
3C029D00 8C42008C 8C44000C 8C430000 54830005 3C029D00 8C430008 8C420004
AC620000 3C029D00 8C43008C 8C64000C 24840001 AC64000C 8C42008C 8C44000C
24030064 50830001 AC40000C 03E00008 00000000
'getFPC
27BDFFF8 AFBF0004 00852023 03E42021 ACC40000 8FBF0004 03E00008 27BD0008
'main
27BDFFC8 AFBF0034 AFB60030 AFB5002C AFB40028 AFB30024 AFB20020 AFB1001C
AFB00018 0080A821 00A0B021 00002021 3C059D00 24A500D8 27A60010 0411FFE8
00000000 3C029D00 8C430000 8C700000 8C42009C 3C044743 0040F809 24845000
00409021 3C0204C4 3442B401 0202102A 54400006 00102FC2 26020003 2A050000
0045800B 10000003 00102883 00B08021 00102843 3C119D00 8E220080 00A02021
0040F809 00052FC3 8E230064 00402021 0060F809 02402821 00408821 24120001
3C109D00 10000009 24140001 8E02009C 0040F809 3C044100 02202021 0260F809
00402821 00408821 001290C0 8E130068 8E020080 3404FFFF 0040F809 00002821
02202021 0260F809 00402821 5054FFEF 8E130064 3C030100 3C02BF88 AC431064
3C02BF88 AC401068 8EA40000 3C029D00 8C420088 00041880 00621021 8C420000
30420065 1440000B 3C109D00 8E020010 24050008 0040F809 00003021 8E020010
8EA40000 24050065 0040F809 00003021 3C109D00 8E13008C 8E020024 8EA40000
0040F809 24050007 AE620008 8E13008C 8E020028 0040F809 8EA40000 24030001
00431004 AE620004 8E02001C 8EA40000 0040F809 24050005 8FA40010 8E0200B0
3C039D00 24630000 00641821 AC430000 8E02008C 8EC30000 AC430000 8E02008C
AC40000C 24020008 12420005 24100030 3A520040 24020060 00008021 0052800A
3C029D00 8C42007C 0040F809 02202021 3C03BF80 AC620E20 36108000 3C02BF80
AC500E00 2403001C 3C02BF88 AC4310E4 24030004 3C02BF88 AC4310E8 3C020100
3C03BF88 AC621034 3C03BF88 AC621064 3C03BF88 AC621068 8FBF0034 8FB60030
8FB5002C 8FB40028 8FB30024 8FB20020 8FB1001C 8FB00018 03E00008 27BD0038
End CSub
Edited by matherp 2017-04-25
 
oldtimer
Newbie

Joined: 02/12/2016
Location: Australia
Posts: 18
Posted: 04:21pm 24 Apr 2017
Copy link to clipboard 
Print this post

Matherp and White Wizard - many thanks for both your suggestions - Matherp - your cfunction code works perfectly - WW - I have a second explore 64 board (the chip and SD card holder very kindly soldered up by grogster ) so when putting the rest of the smd,s on the board -Ill just dispense with that particular 10K (close to the 2n7002) which should produce the required result - a simple and elegant solution - many thanks and Ill post the result -

On another matter - Matherp - some time ago you posted a code for a functioning CHT gauge - you may remember I contacted you with error problems - but as I hadn't attached the MCP 342 ADC or DS 18B20 sensor - the code returned errors - would it be possible to send a diagram of how you wired up the ADC and Temp Sensor to the processor and the pin numbers you used to achieve the display - I can use either the 28 pin back pack or the explore 64 backpack- both with the ILI 9341 display- either one would suit

again many thanks for your input

regards

Oldtimer
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9066
Posted: 04:26pm 24 Apr 2017
Copy link to clipboard 
Print this post

Our father of Cfunctions rarely sleeps.....

Nice one, matherp.
Smoke makes things work. When the smoke gets out, it stops!
 
oldtimer
Newbie

Joined: 02/12/2016
Location: Australia
Posts: 18
Posted: 04:40pm 24 Apr 2017
Copy link to clipboard 
Print this post

White Wizard - just realised - removing the pull down resistor will have to be supplemented with a pull up resistor from pin 53 to the 5 volt line - was getting ahead of myself!!!
 
WhiteWizzard
Guru

Joined: 05/04/2013
Location: United Kingdom
Posts: 2794
Posted: 07:41pm 24 Apr 2017
Copy link to clipboard 
Print this post

  oldtimer said   White Wizard - just realised - removing the pull down resistor will have to be supplemented with a pull up resistor from pin 53 to the 5 volt line - was getting ahead of myself!!!


Yes - you do need to do that (sorry - I should have highlighted that part better maybe!)
  whitewizzard said  ...then I would recommend you remove it and 'convert it' to a pull-up.


One method is to simply 'tombstone'the 10K on the resistor pad connected to PIC pin53, and then solder a thin wire to +v from the 'uppermost' end of the 10K. Just in case you've not heard of 'Tombstone' in SMD speak, it simply means 'stand the component up on one pad'

I only recommend you do this if you're confident at soldering SMDs as otherwise PCB tracks could get damaged - especially 'thin' ones. Best way I find to remove small (two pad) SMD components is to cover them with more solder (to effectively short out the component's pads) then using a pair of metal tweezers then grab the component while applying the iron to melt the solder. Then use wick + liquid flux to remove all solder. NOTE - this has to be done quickly so you do not heat-damage the PCB (i.e. minimise soldering-iron contact time). These are just 'tips' in case you're not 100% confident
For everything Micromite visit micromite.org

Direct Email: whitewizzard@micromite.o
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024