Hi from Reunion Island !

Post Reply
Jules974
Posts: 3
Joined: Wed Nov 09, 2016 6:22 pm

Hi from Reunion Island !

Post by Jules974 » Wed Nov 09, 2016 9:02 pm

New to the forum, I first of all wanted to thanks all people that have been involved in this project, because it took me less than 1hour from opening my blue pill, soldering headers, to making a led blink with Arduino IDE :) (and I'm very slow in soldering process!)

I have used avr in the past, gave a try at nxp lpc, and now start with stm32 !

Having a part time job at the moment, I spend half of my day making (or at least, trying to make!) and it seems I will love this place. :D

User avatar
RogerClark
Posts: 7471
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: Hi from Reunion Island !

Post by RogerClark » Wed Nov 09, 2016 9:06 pm

Welcome @Jules974

I'm glad it was a simple process to get it working.

I think you were slightly lucky that your Blue Pill did not have a hardware fault. A lot of people have to do extra soldering.

BTW. Did you need to solder the additional 1.8k resistor for USB pullup, or did the SMD resistor on the board work OK for you?

Jules974
Posts: 3
Joined: Wed Nov 09, 2016 6:22 pm

Re: Hi from Reunion Island !

Post by Jules974 » Thu Nov 10, 2016 6:39 am

So, my R10 is marked as 103 (10k ohm).

I intially used the usb serial and reset option to upload my programs within 1hour, then it took me a bit more time from downloading ST Demonstration GUI to flash the bootloader, and start to use USB. and STM32duino bootloader.

I had once the board that did stayed in DFU, but it seems that everything is working fine for now, without any additionnal resistor needed.

BTW, here is my test code, to dim an RGB led at different rates among analog inputs.
Allow me to test PWM, analogInput at the same time. (while running in "separate threads"...)
(while convincing my wife that i do better things than these design stuff with RGB color dimming encapsulded :P)

[spoiler=My Test Code]

Code: Select all

/*
  RGB LED

  This example alternate an RGB LED color by using the pwmWrite() function
  on STM32F103C8 Blue Pill to fade each color at different rates,
  using 3 analog Inputs

  Created 9 Nov 2016
  By Julien Lacaze

*/

uint8_t ledPin[] = {PA0,PA1,PA2}; // Connect an RGB LED to these pins
                              // or any PWM-capable pin only
int fadeValue[]= {0,0,0};
uint16_t fadeStep[]= {1,1,1};
uint16_t interval= 20;
unsigned long previousMillis[] = {0,0,0};
bool toogle[] = {0,0,0};

uint8_t analogInput[] = {PA5,PA6,PA7};
uint16_t analogValue[3];
uint16_t analogInterval = 5;
uint16_t analogPrevious[] = {0,0,0};
uint16_t analogThreshold = 5;

void setup() {
    for (uint8_t i=0;i<3;i++){
      pinMode(ledPin[i], PWM);  // setup the pin as PWM
    }
}

void loop()  {
  for (uint8_t i=0;i<3;i++){   
    if (millis() - analogPrevious[i] > analogInterval) {
      analogPrevious[i] = millis();
      analogValue[i] = abs(analogRead(analogInput[i])-analogValue[i]) >= analogThreshold ? analogRead(analogInput[i]) : analogValue[i];
      fadeStep[i] = analogValue[i];
    }
  }
  for (uint8_t i=0;i<3;i++){    
    if (millis() - previousMillis[i] > interval) {
      previousMillis[i] = millis();
      if (!toogle[i]){
        fadeValue[i]= fadeValue[i]+fadeStep[i]>65535 ? 65535 : fadeValue[i]+fadeStep[i];
        toogle[i] = fadeValue[i]==65535 ? 1 : 0;
      }
      else{
        fadeValue[i]= fadeValue[i]-fadeStep[i]<0 ? 0 : fadeValue[i]-fadeStep[i];
        toogle[i] = fadeValue[i]==0 ? 0 : 1;
      }
      pwmWrite(ledPin[i], fadeValue[i]);
    }
  }  
}   
[/spoiler]


Edited due to false resistor value
Last edited by Jules974 on Thu Nov 10, 2016 5:02 pm, edited 1 time in total.

User avatar
RogerClark
Posts: 7471
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: Hi from Reunion Island !

Post by RogerClark » Thu Nov 10, 2016 7:14 am

Bootloader stays in DFU mode if there isnt a valid sketch in the flash

Serial USB is part of the sketch, as the bootloader only does the DFU bit

When the sketch starts it resets the USB bus, and then enumerates as USB Serial (you need the windows drivers from the repo)

stevestrong
Posts: 1821
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany

Re: Hi from Reunion Island !

Post by stevestrong » Thu Nov 10, 2016 2:53 pm

Jules974 wrote:So, my R10 is marked as 103 (1k ohm).
Just to correct the info, 103 means 10 followed by 3 zeros, which is 10k.
Anyway, it may sometimes work.

Jules974
Posts: 3
Joined: Wed Nov 09, 2016 6:22 pm

Re: Hi from Reunion Island !

Post by Jules974 » Thu Nov 10, 2016 5:00 pm

stevestrong wrote:
Jules974 wrote:So, my R10 is marked as 103 (1k ohm).
Just to correct the info, 103 means 10 followed by 3 zeros, which is 10k.
Anyway, it may sometimes work.
Yes, my bad, it is 10k.

Post Reply