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.
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: AustraliaPosts: 1114
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 KingdomPosts: 2929
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
Grogster Admin Group Joined: 31/12/2012 Location: New ZealandPosts: 9584
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!
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 KingdomPosts: 2929
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
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 10180
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.
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 ZealandPosts: 9584
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!
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 KingdomPosts: 2929
Posted: 07:41pm 24 Apr 2017
Copy link to clipboard
Print this post
Yes - you do need to do that (sorry - I should have highlighted that part better maybe!)
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