Can some1 help to port library

Can someone help me port this library?
zouk199
Posts: 15
Joined: Thu Aug 04, 2016 1:47 am

Can some1 help to port library

Post by zouk199 » Tue Apr 25, 2017 9:48 am

https://github.com/adafruit/MAX6675
I want it to work with stm32f401.
Thanks in advance

User avatar
BennehBoy
Posts: 501
Joined: Thu Jan 05, 2017 8:21 pm
Location: Yorkshire
Contact:

Re: Can some1 help to port library

Post by BennehBoy » Wed Apr 26, 2017 10:48 am

I think the best approach would be to try it yourself and ask for specific help on issues which arise.
-------------------------------------
https://github.com/BennehBoy

zouk199
Posts: 15
Joined: Thu Aug 04, 2016 1:47 am

Re: Can some1 help to port library

Post by zouk199 » Wed May 03, 2017 3:28 am

hi mr ben
i tried https://github.com/JChristensen/Thermocouple

can compile

n upload

but doesnt run for some reason.

can u pls help##

Riva
Posts: 42
Joined: Fri May 06, 2016 6:42 am

Re: Can some1 help to port library

Post by Riva » Wed May 03, 2017 7:00 am

How have you got the MAX7765 device connected to your f401 and what f401 are you using?

zouk199
Posts: 15
Joined: Thu Aug 04, 2016 1:47 am

Re: Can some1 help to port library

Post by zouk199 » Fri May 05, 2017 3:45 am

i have max6675 board from ebay and i am using f103rb.original arduino library is attached@@
Attachments
Thermocouple-master.zip
(6.31 KiB) Downloaded 30 times

Riva
Posts: 42
Joined: Fri May 06, 2016 6:42 am

Re: Can some1 help to port library

Post by Riva » Fri May 05, 2017 7:28 am

zouk199 wrote:i have max6675 board from ebay and i am using f103rb.original arduino library is attached@@
The library example compiles fine for me when the F103R is selected but as I have neither an F103R or a MAX6675 I cannot test it.
What I want to know is how you have the MAX6675 connected to the F103R. What pins connected where and what the signal names are on the MAX6675 board (or a link to the ebay listing you bought it from).

zouk199
Posts: 15
Joined: Thu Aug 04, 2016 1:47 am

Re: Can some1 help to port library

Post by zouk199 » Fri May 05, 2017 7:41 am

thanks riva for trying d library

i connect spi sck to pin d13/pa5
spi cs to d10/pb6
spi miso to d12/pa6
Attachments
unnamed.jpg
unnamed.jpg (25.78 KiB) Viewed 627 times

edogaldo
Posts: 291
Joined: Fri Jun 03, 2016 8:19 am

Re: Can some1 help to port library

Post by edogaldo » Fri May 05, 2017 9:03 am

zouk199 wrote:i have max6675 board from ebay and i am using f103rb.original arduino library is attached@@
I'm confused, are you using a F103 or a F401?!
Could you please provide clear information?
Which mcu?
Which board? Could you post a picture?
Which core? Is your core up-to-date!?

Riva
Posts: 42
Joined: Fri May 06, 2016 6:42 am

Re: Can some1 help to port library

Post by Riva » Fri May 05, 2017 9:26 am

The MISO/SCK appear to be on the right pins, SS is user definable though the F103R variant file places it on PA4.

Code: Select all

static const uint8_t SS   = BOARD_SPI1_NSS_PIN;
static const uint8_t SS1  = BOARD_SPI2_NSS_PIN;
static const uint8_t MOSI = BOARD_SPI1_MOSI_PIN;
static const uint8_t MISO = BOARD_SPI1_MISO_PIN;
static const uint8_t SCK  = BOARD_SPI1_SCK_PIN;

#define BOARD_SPI1_NSS_PIN      PA4
#define BOARD_SPI1_SCK_PIN      PA5
#define BOARD_SPI1_MISO_PIN     PA6
#define BOARD_SPI1_MOSI_PIN     PA7

I'm hoping the problem is the MAX6675 library code defines new values for SCK/MISO/MOSI and commenting them out (or deleting them) will fix your issue.
Try to avoid using Arduino style pin numbering (1,2,3 etc) in your code and elect to use the STM32 naming convention instead (PA1,PA2,PA3 etc)
Open the Thermocouple.cpp file and comment out the three lines...

Code: Select all

//#define MOSI  11    //master out slave in (not connected)
//#define MISO  12    //master in slave out
//#define SCK   13    //serial clock
If your using the oneTC.pde example to test it then don't forget to change #define csTC1 10 to #define csTC1 PB6

ag123
Posts: 854
Joined: Thu Jul 21, 2016 4:24 pm

Re: Can some1 help to port library

Post by ag123 » Fri May 05, 2017 10:24 am

hi zouk199,

i think riva is right, check your pin assignments, note that selecting a different board could lead you to different pin assignments in the board.c assignments array, you may need to cross reference a schematic and board layout as well. i often have multiple pictures/files opened so that i could be assured i picked the correct pins. in stm32 it gpios is normally referenced by its PAxx .. Pnxx pins. but boards.c use an index into the array to select the pin and may lead to goofs like you may be expecting PAxx but it is literally Pnxx something else.

the other thing is MAX6675.pdf apparently specify a max clock frequency of 4.3 mhz
https://datasheets.maximintegrated.com/ ... AX6675.pdf

the codes seem to target a SPI clock of 1MHZ
https://github.com/JChristensen/Thermoc ... le.cpp#L35

Code: Select all

 SPI.setClockDivider(SPI_CLOCK_DIV16); //Set SPI clock freq to 1MHz
for thermocouples you won't really need a high spi bus speed and can start with low values and increasing them later
assuming that the system clock is running at 72mhz, SPI_CLOCK_DIV16 would give 4.5mhz
try things like SPI_CLOCK_DIV32, or SPI_CLOCK_DIV64 etc

p.s. you may need to play/mess with the timing of that CS as apparently the specs mentioned it plays a key role in the adc conversion process
Serial Interface
The Typical Application Circuit shows the MAX6675 interfaced with a microcontroller. In this example, the MAX6675 processes the reading from the thermocouple and transmits the data through a serial interface. Force CS low and apply a clock signal at SCK to read the results at SO. Forcing CS low immediately stops any conversion process. Initiate a new conversion process by forcing CS high.
if it is too close between samples it may potentially cause issues. perhaps insert some samping delay between cs timings
e.g. CS_HIGH
delay(1) //ms
CS_LOW
delay_us(1);
value = SPI.transfer16(0x00);
Serial.println(value);

just 2 cents hope it helps

Post Reply