Announcement

Collapse
No announcement yet.

DSPIC30F4012 v230 Source Code

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • ApBerg
    replied
    Originally posted by 6666 View Post
    Thanks for that info Moodz
    had a poke around in mplab and found where you can select programmer
    so lashed out and bought a pickit3 clone
    I hope it works.


    http://www.ebay.com/itm/ws/eBayISAPI...m=350492021662
    Hello 6666,

    Some months ago I have bought one at the same Ebay site, works nice !
    (for programming the logger chip)
    From the ziff socket board I have removed the transparent protection cover...make's swapping the IC easier.

    Best regards.

    AP

    Leave a comment:


  • 6666
    replied
    Thanks for that info Moodz
    had a poke around in mplab and found where you can select programmer
    so lashed out and bought a pickit3 clone
    I hope it works.


    Leave a comment:


  • moodz
    replied
    Originally posted by 6666 View Post
    Hi Moodz
    thanks for the changes to software
    ordered some 30f4012 chips
    but it does not look like my current programmer and software supports 30f4012 chips
    so looks like i have to get a PICkit 2

    Does the PICkit 2 have its own separate programing software
    or can you program the 30f4012 direct from Mplab IDE ?

    I see a few pickit2 clones with all the chip adaptors on ebay but not sure about the programming software .
    thanks

    Pickit 2 or 3 should come with its own programming software. However MPLAB supports it straight off the menu. So you can use either . Of course you need MPLAB to compile the code if thats what you want to do also. I have not tried the pickit clones but I did try an ICD2 programmer clone and it worked fine.

    moodz.

    Leave a comment:


  • 6666
    replied
    Hi Moodz
    thanks for the changes to software
    ordered some 30f4012 chips
    but it does not look like my current programmer and software supports 30f4012 chips
    so looks like i have to get a PICkit 2

    Does the PICkit 2 have its own separate programing software
    or can you program the 30f4012 direct from Mplab IDE ?

    I see a few pickit2 clones with all the chip adaptors on ebay but not sure about the programming software .
    thanks

    Leave a comment:


  • moodz
    replied
    ... a picture says a 1000 words.

    Answer for WM6 and maybe others ...
    Following parameters can be set from menu ( LCD or RS232 )


    1. TXF transmit frequency
    2. TXP transmit ON period.
    3. S1 ON sample pulse 1 on time set from start of TXP (T1 in diagram)
    4. S1 OFF sample pulse 1 off time set from start of TXP (T1 in diagram)
    5. S2 ON sample pulse 2 on time set from start of TXP (T1 in diagram)
    6. S2 OFF sample pulse 2 off time set from start of TXP (T1 in diagram)

    S1 and S2 can be configured for any on and off time during the period TXF including 0 and the maximum ( TXF ) so you can sample during TX or RX or both or disable by setting both to 0.

    TX pulse repeat at TXF frequency rate T1 , T2 etc

    Also shown how sample pulse is inverted but timing remains the same.

    moodz.

    Click image for larger version

Name:	UNIPI_timing.JPG
Views:	1
Size:	28.4 KB
ID:	329621
    Last edited by moodz; 09-21-2011, 10:59 PM. Reason: typo2

    Leave a comment:


  • WM6
    replied
    Originally posted by moodz View Post

    TWO hex releases .... TX is active high ( H ) and TX is active low ( L ) .... with respect to sample times.

    If you set sample pulse 1 ON time ( S1 ) to say 105 us and S1 OFF time to 110 us then your sample 1 pulse will go high at 105 us and low at 110 us. ( ie 5 us pulse starting at 105 us which is 5 us after the TX turns off. Simple .. right !

    I wish to undestand this: how ".. with respect to sample times."?

    Can you explain this by drawing? Thank you in advance!

    Leave a comment:


  • moodz
    replied
    inverting the sample pulse ....

    I tested this just to make sure ....

    lets say you have a 4 Khz TX frequency ( 250 us period ) and a 100 us TX pulse ( does not matter if it is the L or H version firmware ).

    If you set sample pulse 1 ON time ( S1 ) to say 105 us and S1 OFF time to 110 us then your sample 1 pulse will go high at 105 us and low at 110 us. ( ie 5 us pulse starting at 105 us which is 5 us after the TX turns off. Simple .. right !

    Oh dear ... what if your sample circuit wants an active low sample pulse ????

    Well all you do is swap the above settings around !!!

    set S1 ON = 110 us and S1 OFF to 105us and voila your pulse is inverted

    simple again !!!

    Using this method you can even mix and match S1 can be positive ( lo hi lo ) and S2 can be ( hi lo hi ) .... fantastic ... if thats what your sample channels want ...

    moodz.

    Leave a comment:


  • moodz
    replied
    updates and releases v23001 L and H

    Fixed a small limit bug in a timer prefix.

    Press zero button LCD splash screen now replaced by two second timeout splash screen ... the chip starts without you doing anything

    TWO hex releases .... TX is active high ( H ) and TX is active low ( L ) .... with respect to sample times.
    Pick the one that matches your mosfet drive circuit. ( hi = tx on OR low = tx on )

    Metal23_TX_H.zip
    Metal23_TX_L.zip

    Identical functionality except the TX signal is inverted on TX_L

    Now some timing info ... see pic below. ( this is from TX active low code )

    sample pulse 1 and 2 have been set to the extreme ends of a TX cycle ( ie TX on and off periods ) and minimum sample width ( 2 steps ). in this case the TX frequency is 4 Khz so the period is 250 us. The TX on time is 125 us ( adjustable from 0 to 250 us in 66 ns steps )

    The minimum width of a sample pulse is 66 ns ( no prize for guessing what the maximum width is ) ..... The minimum step increase in pulse width (ie sample resolution ) is 33 ns.

    So you should have no problem sampling wherever you want to during TX ON or OFF at any practical resolution, sample pulse width, TX frequency, TX pulse width ... ( is there something I forgot in that list ?? )


    moodz

    Click image for larger version

Name:	PULSE.JPG
Views:	1
Size:	151.4 KB
ID:	329614
    Last edited by moodz; 09-21-2011, 01:52 PM. Reason: update2

    Leave a comment:


  • moodz
    replied
    code building ....

    For those building the code under MPLAB a good build should have an output like this ...

    note you can also see the tool versions in the output below ....

    regards,

    moodz

    Release build of project `C:\WORK\METAL\Metal23RELEASE\23001H\Metal23.mcp' started.
    Language tool versions: pic30-as.exe v3.23, pic30-gcc.exe v3.25, pic30-ld.exe v3.23, pic30-ar.exe v3.25
    Wed Sep 21 20:51:01 2011
    ----------------------------------------------------------------------
    Clean: Deleting intermediary and output files.
    Clean: Deleted file "C:\WORK\METAL\Metal23RELEASE\23001H\main.o".
    Clean: Deleted file "C:\WORK\METAL\Metal23RELEASE\23001H\serial.o" .
    Clean: Deleted file "C:\WORK\METAL\Metal23RELEASE\23001H\pwm.o".
    Clean: Deleted file "C:\WORK\METAL\Metal23RELEASE\23001H\eeprom_rw .o".
    Clean: Deleted file "C:\WORK\METAL\Metal23RELEASE\23001H\ADC.o".
    Clean: Deleted file "C:\WORK\METAL\Metal23RELEASE\23001H\timers.o" .
    Clean: Deleted file "C:\WORK\METAL\Metal23RELEASE\23001H\vars.o".
    Clean: Deleted file "C:\WORK\METAL\Metal23RELEASE\23001H\main_loop .o".
    Clean: Deleted file "C:\WORK\METAL\Metal23RELEASE\23001H\RS232menu .o".
    Clean: Deleted file "C:\WORK\METAL\Metal23RELEASE\23001H\QEImenu.o ".
    Clean: Deleted file "C:\WORK\METAL\Metal23RELEASE\23001H\lcd.o".
    Clean: Deleted file "C:\WORK\METAL\Metal23RELEASE\23001H\Metal23.c of".
    Clean: Deleted file "C:\WORK\METAL\Metal23RELEASE\23001H\Metal23.h ex".
    Clean: Done.
    Executing: "C:\Program Files\Microchip\mplabc30\v3.25\bin\pic30-gcc.exe" -mcpu=30F4012 -x c -c "main.c" -o"main.o" -Wall -Os -legacy-libc
    Executing: "C:\Program Files\Microchip\mplabc30\v3.25\bin\pic30-gcc.exe" -mcpu=30F4012 -x c -c "serial.c" -o"serial.o" -Wall -Os -legacy-libc
    Executing: "C:\Program Files\Microchip\mplabc30\v3.25\bin\pic30-gcc.exe" -mcpu=30F4012 -x c -c "pwm.c" -o"pwm.o" -Wall -Os -legacy-libc
    Executing: "C:\Program Files\Microchip\mplabc30\v3.25\bin\pic30-gcc.exe" -mcpu=30F4012 -c "eeprom_rw.s" -o"eeprom_rw.o"
    Executing: "C:\Program Files\Microchip\mplabc30\v3.25\bin\pic30-gcc.exe" -mcpu=30F4012 -x c -c "ADC.c" -o"ADC.o" -Wall -Os -legacy-libc
    Executing: "C:\Program Files\Microchip\mplabc30\v3.25\bin\pic30-gcc.exe" -mcpu=30F4012 -x c -c "timers.c" -o"timers.o" -Wall -Os -legacy-libc
    Executing: "C:\Program Files\Microchip\mplabc30\v3.25\bin\pic30-gcc.exe" -mcpu=30F4012 -x c -c "vars.c" -o"vars.o" -Wall -Os -legacy-libc
    Executing: "C:\Program Files\Microchip\mplabc30\v3.25\bin\pic30-gcc.exe" -mcpu=30F4012 -x c -c "main_loop.c" -o"main_loop.o" -Wall -Os -legacy-libc
    Executing: "C:\Program Files\Microchip\mplabc30\v3.25\bin\pic30-gcc.exe" -mcpu=30F4012 -x c -c "RS232menu.c" -o"RS232menu.o" -Wall -Os -legacy-libc
    Executing: "C:\Program Files\Microchip\mplabc30\v3.25\bin\pic30-gcc.exe" -mcpu=30F4012 -x c -c "QEImenu.c" -o"QEImenu.o" -Wall -Os -legacy-libc
    Executing: "C:\Program Files\Microchip\mplabc30\v3.25\bin\pic30-gcc.exe" -mcpu=30F4012 -x c -c "lcd.c" -o"lcd.o" -Wall -Os -legacy-libc
    Executing: "C:\Program Files\Microchip\mplabc30\v3.25\bin\pic30-gcc.exe" -mcpu=30F4012 "main.o" "serial.o" "pwm.o" "eeprom_rw.o" "ADC.o" "timers.o" "vars.o" "main_loop.o" "RS232menu.o" "QEImenu.o" "lcd.o" -legacy-libc -o"Metal23.cof" -Wl,-L"C:\Program Files\Microchip\MPLAB C30\lib",--script="..\..\..\..\Program Files\Microchip\mplabc30\v3.25\support\dsPIC30F\gl d\p30f4012.gld",--defsym=__MPLAB_BUILD=1,--heap=200,--stack=320,--no-check-sections,-Map="Metal23.map",--report-mem,--cref,--warn-section-align


    Program Memory [Origin = 0x100, Length = 0x7f00]

    section address length (PC units) length (bytes) (dec)
    ------- ------- ----------------- --------------------
    .text 0x100 0x38e0 0x5550 (21840)
    .const 0x39e0 0x592 0x85b (2139)
    .text 0x3f72 0x86c 0xca2 (3234)
    .dinit 0x47de 0x294 0x3de (990)
    .text 0x4a72 0x734 0xace (2766)
    .isr 0x51a6 0x2 0x3 (3)

    Total program memory used (bytes): 0x78fc (30972) 63%


    Data EEPROM Memory [Origin = 0x7ffc00, Length = 0x400]

    section address length (PC units) length (bytes) (dec)
    ------- ------- ----------------- --------------------
    _011012a04e79c198 0x7ffc00 0x1c 0x1c (2

    Total data EEPROM used (bytes): 0x1c (2 2%


    Data Memory [Origin = 0x800, Length = 0x800]

    section address alignment gaps total length (dec)
    ------- ------- -------------- -------------------
    .nbss 0x800 0 0x26 (3
    .ndata 0x826 0 0x20 (32)
    .nbss 0x846 0 0x8a (13
    .ndata 0x8d0 0 0xc (12)
    .nbss 0x8dc 0 0xc (12)
    .ndata 0x8e8 0 0x4 (4)
    .nbss 0x8ec 0 0x2 (2)
    .data 0x8ee 0 0x242 (57
    .dconst 0xb30 0 0x24 (36)
    .data 0xb54 0 0xa (10)
    .bss 0xb5e 0 0x2 (2)
    .data 0xb60 0 0x2 (2)
    .dconst 0xb62 0 0x2 (2)
    .data 0xb64 0 0x2 (2)
    .bss 0xb66 0 0x2 (2)
    .heap 0xb68 0 0xc8 (200)

    Total data memory used (bytes): 0x430 (1072) 52%


    Dynamic Memory Usage

    region address maximum length (dec)
    ------ ------- ---------------------
    heap 0xb68 0xc8 (200)
    stack 0xc30 0x3d0 (976)

    Maximum dynamic memory (bytes): 0x498 (1176)

    Executing: "C:\Program Files\Microchip\MPLAB C30\bin\pic30-bin2hex.exe" "C:\WORK\METAL\Metal23RELEASE\23001H\Metal23.c of"
    Loaded C:\WORK\METAL\Metal23RELEASE\23001H\Metal23.cof.
    ----------------------------------------------------------------------
    Release build of project `C:\WORK\METAL\Metal23RELEASE\23001H\Metal23.mcp' succeeded.
    Language tool versions: pic30-as.exe v3.23, pic30-gcc.exe v3.25, pic30-ld.exe v3.23, pic30-ar.exe v3.25
    Wed Sep 21 20:51:07 2011
    ----------------------------------------------------------------------
    BUILD SUCCEEDED

    Leave a comment:


  • moodz
    replied
    Originally posted by Monolith View Post
    Thanks for the explanation. So I can use the pulse either way 0 to 5V and 5V to 0. The timing resolution is so high that I can compensate for any switching delay generated by the level translator.

    Still, to take a 3us sample I would want the switching delay to be less than 100ns on and again off. This means a fairly fast level translator. I need to look at some datasheets and search for possible circuits.

    Monolith
    Correct ... I have played with sample pulses at 1us ...no problemo.

    regarding the mosfet driver ... depends if they are P or N I suppose. I am no Microchip fanboy but they do make a fairly good range of driver chips .... there are other ones out there.

    eg TC4421

    • High Peak Output Current: 9A
    • Wide Input Supply Voltage Operating Range:
    - 4.5V to 18V
    • High Continuous Output Current: 2A Max
    • Fast Rise and Fall Times:
    - 30 ns with 4,700 pF Load
    - 180 ns with 47,000 pF Load
    • Short Propagation Delays: 30 ns (typ)
    • Low Supply Current:
    - With Logic ‘1’ Input – 200 μA (typ)
    - With Logic ‘0’ Input – 55 μA (typ)
    • Low Output Impedance: 1.4Ω (typ)
    • Latch-Up Protected: Will Withstand 1.5A Output
    Reverse Current
    • Input Will Withstand Negative Inputs Up To 5V
    • Pin-Compatible with the TC4420/TC4429
    6A MOSFET Driver

    moodz.
    Last edited by moodz; 09-21-2011, 06:57 AM. Reason: typo

    Leave a comment:


  • Monolith
    replied
    Originally posted by moodz View Post
    That was badly explained ..... should read because you can sample at any time across each TX cycle either the high level or the low level can be used to drive a mosfet.
    Thanks for the explanation. So I can use the pulse either way 0 to 5V and 5V to 0. The timing resolution is so high that I can compensate for any switching delay generated by the level translator.

    Still, to take a 3us sample I would want the switching delay to be less than 100ns on and again off. This means a fairly fast level translator. I need to look at some datasheets and search for possible circuits.

    Monolith

    Leave a comment:


  • moodz
    replied
    Originally posted by moodz View Post
    The pulse is positive 0 to 5 volts.however because you can sample at any time during tx or tx period you can use either type of mosfet ...think about it

    to invert the sample pulse you set the off time to occur before the on time for each sample pulse
    moodz.
    That was badly explained ..... should read because you can sample at any time across each TX cycle either the high level or the low level can be used to drive a mosfet.

    Leave a comment:


  • moodz
    replied
    positive pulse

    The pulse is positive 0 to 5 volts.however because you can sample at any time during tx or tx period you can use either type of mosfet ...think about it

    to invert the sample pulse you set the off time to occur before the on time for each sample pulse
    moodz.

    Leave a comment:


  • Monolith
    replied
    About the pulse outputs of the UNIPI.

    The TX pulse drives the mosfet driver. Is this pulse a positive pulse?
    What would be a good level shifter or translator?

    The same question also for the sample pulses. If they need to be level shifted or translated, and we want to keep the precision timing, we need to have a fast circuit.

    Does anybody have a recommended circuit?

    Monolith

    Leave a comment:


  • 6666
    replied
    Ok so we keep away from the 20I thanks

    Leave a comment:

Working...
X