Menu

PWMout with variable frequency and duty.

Haroen
2024-04-06
2024-04-21
<< < 1 2 3 > >> (Page 2 of 3)
  • Anobium

    Anobium - 2024-04-12

    No. You should always use the latest compiler and there has been many many changes since the version you are currently using.

    My advice would be to stay up to date, always.

     
  • kent_twt4

    kent_twt4 - 2024-04-12

    The AVR HPWM Programs compile just fine on GCB version 0.99.01

    So I would suspect a corrupt toolchain?, could try reinstall or go with Anobiums suggestion of updated compiler.

    The Port assignments to HPWM channels look good. There are Nano pinout diagrams that have the OCnx locations like https://descubrearduino.com/wp-content/uploads/2018/12/arduino-nano-pinout-1024x876.jpg

     
  • Haroen

    Haroen - 2024-04-13

    Same error problem in newest GCstudio.

    Will it be easier to program PWM just to switch to a PIC chip instead?

     

    Last edit: Haroen 2024-04-13
  • kent_twt4

    kent_twt4 - 2024-04-13

    Copied the make hex output window from 0.99.01 from help example, no errors:

    20:03:04 G+Stool started with parameter 'hex' -> processing C:\GCB@Syn\G+Stools\makeHEX.bat
    Source-File = C:\GCB@Syn_Programs\Forum\HPWM_Nano_m328.gcb
    Target-File = C:\GCB@Syn_Programs\Forum\HPWM_Nano_m328.hex
    Compiler Version: 0.99.01 2022-01-27 (Windows 64 bit) : Build 1073 Program Memory: 724/32768 bytes (2.21%) RAM: 11/2048 bytes (0.54%) OSC: 16Mhz Chip: MEGA328
    Duration: 1.8 Seconds.

    EDIT: Can you blink an led by just setting a port pin on and off?
    EDIT2: Looks like a programmer problem, I use the AVR MKII ISP, so no help with AVRDude

     

    Last edit: kent_twt4 2024-04-13
  • Haroen

    Haroen - 2024-04-16

    Took me a while but I found the problem(s):
    1)First uninstall the old GCstudio before installing the new one.
    2)GCstudio is on another pc where I had an ArduinoNano USB-C type that has an old bootloader and 2 extra resistors on the board.
    I now have ArduinoNano328p selected in GCstudio but what should I select for the OLD bootloader?
    3)Programming a ArduinoNano µUSB-type that works well on SynWrite but gives errors with GCstudio PWMcode:

    Downloading program ...Arduino Nano/ProMini 328p@57600
    Calling : C:\Program Files\GCstudio\gcbasic..\avrdude\avrdude.exe
    Parameters : -c Arduino -u -b 57600 -P COM7 -p ATMEGA328 -U flash:w:"D:_HR_GCB\HPWM from help.hex":i
    avrdude.exe: "safemode" feature no longer supported

    avrdude.exe: AVR device initialized and ready to accept instructions

    Reading | ################################################## | 100% 0.00s

    avrdude.exe: Device signature = 0x1e950f (probably m328p)
    avrdude.exe: Expected signature for ATmega328 is 1E 95 14
    Double check chip, or use -F to override this check.

    avrdude.exe done. Thank you.

    Enjoying GCBASIC ?

    Please donate to help support the operational costs of the project. Donate via http://paypal.me/gcbasic

    A warning has been generated:

    Warning: The chip may not have programmed properly. Programmer returned status (1)

    (Total time: 4.937 seconds)
    Done

    • The terminal process "C:\Windows\SysNative\WindowsPowerShell\v1.0\powershell.exe -Command & 'C:\Program Files\GCstudio\gcbasic\GCBASIC.EXE' 'D:_HR_GCB\HPWM from help.gcb' /NP /S:use.ini /F:N" terminated with exit code: 1.
     
    • Anobium

      Anobium - 2024-04-16

      I think you should install GCSTUDIO in C:\GCSTUDIO

      Many of the supporting toolchain applications will not work when in installed into PROGRAM FILES. This is not a constraint of GCSTUDIO all the supporting applications.

      When installed into C:\GCSTUDIO what happens?

       
  • Haroen

    Haroen - 2024-04-16

    Installed in C:\GCSTUDIO and now the FlashLED program programs and runs.
    But the PWM program does not:

    Downloading program ...Arduino Nano/ProMini 328p@57600
    Calling : C:\GCstudio\GCBASIC..\avrdude\avrdude.exe
    Parameters : -c Arduino -u -b 57600 -P COM7 -p ATMEGA328 -U flash:w:"D:_HR_GCB\HPWM from help.hex":i
    avrdude.exe: "safemode" feature no longer supported

    avrdude.exe: AVR device initialized and ready to accept instructions

    Reading | ################################################## | 100% 0.00s

    avrdude.exe: Device signature = 0x1e950f (probably m328p)
    avrdude.exe: Expected signature for ATmega328 is 1E 95 14
    Double check chip, or use -F to override this check.

    avrdude.exe done. Thank you.

    Enjoying GCBASIC ?

    Please donate to help support the operational costs of the project. Donate via http://paypal.me/gcbasic

    A warning has been generated:

    Warning: The chip may not have programmed properly. Programmer returned status (1)

    (Total time: 4.093 seconds)
    Done

     
  • kent_twt4

    kent_twt4 - 2024-04-17

    The device signature still not lining up. Have you tried to use device for AVRDude as
    -p m328p ?

     
    • Anobium

      Anobium - 2024-04-17

      Looks like corrupt use.ini ? where is the safe mode warning coming from?

       
  • Haroen

    Haroen - 2024-04-17

    @Anobium, "safe mode" never seen it before!
    @ kent_twt4, "device for AVRDude as -p m328p" where do I put this in the jpg?

     
    • Anobium

      Anobium - 2024-04-17

      Can you post your program and your use.ini. I will try here.

       
  • Haroen

    Haroen - 2024-04-17

    The program is here.

    C:\GCstudio\gcbasic\use.ini

     
    • Anobium

      Anobium - 2024-04-17

      Your program has the incorrect chip specified. The error message is therefore correct.

      Correct the chip.

       
  • kent_twt4

    kent_twt4 - 2024-04-19

    I found my Nano and it was already to go on a breadboard! So I programmed the chip per previous OP gcb program. Again I am using AVRISP MarkII programmer and GCB 0.99.01 compiler.

    ChipID# 0x1E950F
    Freq. 3974
    Duty 49%

    I will try the AVRDude programmer next.

     
  • Anobium

    Anobium - 2024-04-20

    @kent_twt4 This is issue was.. he has the incorrect chip selected.

     
    • Anobium

      Anobium - 2024-04-20

      If you used GCSTUDIO as your starting application then the environment will be managed.

       
      👍
      1
  • Haroen

    Haroen - 2024-04-20

    Anobium is correct, should add a "p" at the end.
    I have not yet tested if the pwm signal works with POTmeters for Freq and Duty.

    While searching the answer I found out that GCbasic can run in legacy mode that I like, but does it contains all upgrades as a full GCbasic?

     
    • Angel Mier

      Angel Mier - 2024-04-21

      Yes, Legacy mode will behave like the old gcbasic while keeping your solution updated with the latest upgrades and features of all the tool chain.

      Angel.

       
      • Haroen

        Haroen - 2024-04-21

        Thanks Angel, I will set GCbasic/Legacy now as my default UI.
        It's just my favorite!

         
  • kent_twt4

    kent_twt4 - 2024-04-20

    Glad you got it sorted.

     
  • Haroen

    Haroen - 2024-04-21

    I have tested the pwm signal that works with Frequency 1-255KHz and Duty 0-100% all Step=1.
    Is it possible to get a higher Frequency resolution of Step=0,1 or 0,25 with ReadAD10 range 0-1023?

     
  • kent_twt4

    kent_twt4 - 2024-04-21

    No increased resolution for HPWM and AVRs. Byte sized variables were used to keep library overhead low so that HPWM will also work on say a tiny13A.

    Increasing the frequency resolution would be an interesting project.

     
  • Haroen

    Haroen - 2024-04-21

    Does this mean that on a pic18F... a higher resolution for frequency could be possible?

     
    • Anobium

      Anobium - 2024-04-21

      No, not the correct assumption.

      Some AVRs, the LGT, and some PICs have higher ADC and/or higher PWM resolution.

      So, you need to seleca microcontroller with the resolution you require then you need to check the GCBASIC capability.

      ADC. 8, 10 and 12 bit are support.
      PWM. For the PIC 8,10 and 16 resolution is support. Where 16 bit will in depth knowledge of from the datasheet. For AVR 8 bit, but, higher resolutions are possible ( as Kent says ) by direct access to the registers. For LGT 8 and 10 bit resolution.

      For any microcontroller you can directly access the registers and using the datasheet change the resolution and frequency to meet your needs.

       
  • kent_twt4

    kent_twt4 - 2024-04-21

    I think there is practical way to test the resolution of the AVR pwm frequency. I mentioned a previous link on how to set up some servo code. I would determine the freq. of interest, then load the registers accordingly. From that point add to the register by one and note the frequency change and so forth would inform just what resolution is possible?

     
<< < 1 2 3 > >> (Page 2 of 3)

Log in to post a comment.