This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Beginner needing help with basic structure and pwm

I am a complete beginner, working through the tutorials and trying not to ask basic questions. However, I am up against a customer time limit and need some help. I am trying to create a program similar to nrf Blinky and soft LED. I need remote on/off and a 0 to 100% control of a 1KHz pwm signal that I can select on an app, and the device will follow. Think of as remote dimming control. I'm using the Murata WSM-BL241-ADA-008 MBN52832 and laid out my pcb to match the Muarata dev board connections. I've downloaded S132 and the Blinky example to my design and the board is alive and functioning as expected. So basically now I need some guidance on where to start adding advertising, the service, the raw data etc for pwm functionality to my version of Blinky. Thank you!

Parents
  • Thanks for the link. I did see that earlier and have been working my way through it however I am getting an error when trying to compile the code.

    L6050U: The code size of this image (34532 bytes) exceeds the maximum allowed for this version of the linker.

    Apparently I'm using MDK-Lite which I downloaded via a link in the SDK.

  • Are you sure you have added the code at the right place in the folder structure? The compiler_abstraction.h file can be found in nRF5_SDK_15.0.0_a53641a\modules\nrfx\mdk\. If you open SES, right click on Project -> Edit Options -> change to Common Private Configuration -> Preprocessor -> User Include Directories, you can see the mdk folder at the bottom:

    Go to the location of your segger folder & see if that is at the correct location. You might need to add an extra folder at the top of the folder structure to get the correct include directories. You could also change the include directories location, but then you would probably need to do this for multiple instances.

    Basically, you want to make sure that the folder structure is identical to the other examples located in the SDK folder.

  • Its in the right location. Not all files are missing. I spent most of the night adding include file locations, still have errors. I am out of time and in danger of losing the client.

    If anyone offers code writing services, I am looking for someone to write a solution for me. I will come back to this later when I have time.

    EDIT: So, after a windows update and reboot, all seems to be well and the project compiles perfectly.

    Thank you guys for all your help. I still have a ton of questions - I have no idea how to receive a value from an app and use it to alter pwm duty cycle yet.

  • Here is an example based on ble_app_uart + PWM driver for SDK 15. You can control the PWM duty cycle, by sending values in the range from 0 to 100, either using nRF Toolbox or nRF Connect. A 1KHz PWM is generated at pin 20 (led 4). Note that this is just a very quick prototype done in 10min, for an end-product you might want to create your own custom service for this.

    Extract the .rar file in the ble_peripheral folder.

    ble_app_uart_pwm_driver_1KHz.rar

    EDIT:

    Here is the custom service tutorial + PWM Driver. Write to the custom characteristic to adjust the PWM duty cycle.

    ble_app_template_pwm_driver.rar

  • Thanks! This works fantastic!

    I changed the pin that the PWM signal is present on and my product dims almost perfectly!

    Couple of questions: Sending a value of 100 turns off the output, not sure if this could be changed to a 100% duty cycle?

    EDIT: FIXED THIS BY CHANGING

    if(duty_cycle >= 1000)
        {
            seq_values->channel_0 = 1000;
        }

    TO

    if(duty_cycle > 1000)
        {
            seq_values->channel_0 = 0;
        }

    How do I change the advertising and connected LED's to different pins? The pwm pin and advertising led share the same io now and I need to move or delete the led function.

    If I want to run an additional service, a custom one, do I need to write that in another file? I want to read the devices temperature, hit a button on the app and send the pwm to 0, hit again and toggle back the original pwm vale. That may be an app side job though.

    I tried incorporating the custom service tutorial into the pwm example. It did not work very well. Slight smile

    Id like to thank you all for helping me learn this stuff and being patient with me while I fumble my way around.

  • Take a look how the ble_blinky application does this in the ble_peripheral folder of sdk 15. The LEDs are defined in main.c:

    #define ADVERTISING_LED BSP_BOARD_LED_0 /**< Is on when device is advertising. */
    #define CONNECTED_LED BSP_BOARD_LED_1 /**< Is on when device has connected. */

    BSP_BOARD_LED_0 & BSP_BOARD_LED_1 are defined in boards.h. I would try to understand the code & take a look at the infocenter documentation to find out how this simple example works & how the LEDs are defined.

    Good luck with future development!

Reply Children
No Data
Related