Temperature measuring

Discussion on projects that are created by users and posted on mikroElektronika website.
Post Reply
Author
Message
lukajokic
Posts: 7
Joined: 11 May 2020 07:58

Temperature measuring

#1 Post by lukajokic » 11 May 2020 08:14

Hi,

Currently i am working on a project where i need to measure temperature on 4 different places. I am using PIC18 on EasyPIC dev board with 2 mikroBUS sockets,
so i tought of using a shuttle click with 4 RTD clicks. My question is, is it possible to use 4 RTD clicks at the same time since they are using the same SPI, and how to do it? And if not, is there any possible solution for this problem (maybe using clicks for thermocouples, or something similar)?

Kind regards,
Luka

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: Temperature measuring

#2 Post by filip » 12 May 2020 08:59

Hi,

Yes, it is possible to use multiple RTD clicks in one project.

For example, for the EasyPIC7 you have two mikroBUS sockets, so you should define CS pins as output :

Code: Select all

void systemInit()
{
    mikrobus_gpioInit( _MIKROBUS1, _MIKROBUS_CS_PIN, _GPIO_OUTPUT );  // set CS on mikroBUS1 as output
    mikrobus_gpioInit( _MIKROBUS2, _MIKROBUS_CS_PIN, _GPIO_OUTPUT ); // set CS on mikroBUS2 as output
    mikrobus_spiInit( _MIKROBUS1, &_RTD_SPI_CFG[0] );
    mikrobus_logInit( _LOG_USBUART, 9600 );

    Delay_ms( 100 );
}
Then you should successively initialize the desired RTD click in applicationInit function before reading its value :

Code: Select all

rtd_spiDriverInit( (T_RTD_P)&_MIKROBUS1_GPIO, (T_RTD_P)&_MIKROBUS1_SPI );
or

Code: Select all

rtd_spiDriverInit( (T_RTD_P)&_MIKROBUS2_GPIO, (T_RTD_P)&_MIKROBUS2_SPI );
Regards,
Filip.

lukajokic
Posts: 7
Joined: 11 May 2020 07:58

Re: Temperature measuring

#3 Post by lukajokic » 12 May 2020 12:09

Hi,

Filip, thak you very much on your answer!
I am new to this and i would like to ask another question, since i googled it but i could not find an answer.
The thing is: is it possible to use multiple SPI devices on the same mikroBUS socket (with Shuttle click) and if it is possible how to do it?
I know that for I2C communication there is a I2C MUX 2 click which makes possible to use four I2C devices on same mikroBUS socket, but is there a way to do it with devices that use SPI? I am asking this because i need to use 4 RTD clicks and 4-20mA R click and they all use SPI communication. So, a Shuttle click would expand one mikroBUS socket to four sockets plus the second mikroBUS socket would make five sockets, which is perfect for this project :D

Thanks in advance,
Luka

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: Temperature measuring

#4 Post by filip » 13 May 2020 08:22

Hi,

Yes, you can use multiple click board with Shuttle click, but in the case of SPI oriented click boards you will need a separate CS line for each one.

If the click boards use the same CS line there will be collision on SPI bus, as all of them will communicate at the same time (the Chip Select line should select a single sensor at a time).

Regards,
Filip.

lukajokic
Posts: 7
Joined: 11 May 2020 07:58

Re: Temperature measuring

#5 Post by lukajokic » 13 May 2020 08:25

Filip, thank you very much! I will try to implement this :D

Post Reply

Return to “User Projects”