I am back! )
So I observed a very interesting detail, guess what?
Yes probably you got it. But anyway I want to mention for the others who not.
I found that no one from the selected 15th participants was decided to go for any of the three proposed ideas from the main post of the PSoC 4 Smarter Life Design Challenge.
Now think about it if you will see at least one of this proposed project in this Design Challenge I think you will like that.
And guess again yes you are right I decided to join the contest with proposed project "Bluetooth-Enabled Smart Shoe".
I will based on the main block diagram so I copy paste it here and will come in the next post with more clear details of what I will plan to do.
In the mid time I think before 17 of January I have a great chance to complete this project. Lets see )
Day 2.
So today I want to present the modified block diagram as you can see below.
1. The Thermistor was removed because the obtained module with GY-86 includes the following sensors:
3-axis gyroscope + triaxial accelerometer + three-axis magnetic field + pressure/altimeter + temperature.
These 3 IC are: MPU6050 + HMC5883L + MS5611. All these sensors will be accessed through I2C bus.
This GY-86 module cost: £10.79 and was ordered from ebay here: 1PC 10DOF IMU MS5611 HMC5883L MPU6050 MWC Flight Control Sensor Module | eBay
2. For the Analog sensor I select the FSR (Force Sensitive Resistor) this will help me to sens if the foot is pressing the ground or not.
This component cost £5.39 and was ordered from here Cool Components Force Sensitive Resistor 0.5 inch
3. The Bluetooth module selected to be in Class 2, so less power consumption is required for it wireless link but also it is not necessary to use Class 1 module because
the mobile phone which will monitoring all the activity from sensors will be in 10 meter area. So Class 2 is definitely perfect option.
This module cost £17 was obtained from here: Order
4. The RGB LED with a push button will be used from the PSoC 4 Pioneer Kit.
For all other components which are not exist on PSoC 4 Pioneer Kit will be soldered to the Arduino ProtoShield Kit.
This component cost £12.48 and was ordered from here Cool Components Arduino ProtoShield Kit
Obviously there much cheaper option for Arduino ProtoShield Kit from other online shop, but I decide to order everything from one place in order to save on cost delivery.
5. Finally the hardware component closed with the single 1xAA battery holder. This is nice option because it pre-include the circuit of DC to DC Step Up for 5V.
This component cost £8.21 and was ordered here Cool Components 5V DC to DC Step Up - 1xAA
Finally I did not apply before for free PSoC 4 Pioneer Kit and order one for me from Farnell here:CY8CKIT-042 - CYPRESS SEMICONDUCTOR - CY8C42, PSOC 4, PIONEER KIT, EVAL | Farnell UK
which cost me £16.89 + 20% VAT
That's it. Now I am waiting for all components.
See you soon )
Figure 2. The Block Diagram of the project
Day 3.
Part 3.1
Now in the mid time of waiting the ordered components.
I decided to view this video The Cypress PSoC 4 and the Smarter Life
and also quickly scroll through all these documentations PSoC 4 Pioneer Kit
Finally I come up with the next ideas which will plan to do:
The firmware on PSoC 4 Pioneer Kit which include the PSoC4200 will be written in order to been compatible with PSoC4100 family.
Why? So let go for quick explanation. As you can see below the figure 3 the main differences are:
- The clock frequency is higher in PSoC4200 (48MHz) comparing to the PSoC4100 (24Mhz)
- The PSoC4200 have 4 additional programmable UDB blocks
So the requirement in the block diagram of figure 2 are:
- x1 UART can be used through SCB
- x1 I2C can be used through SCB
- x1 OpAmp
- x1 12bit ADC
- x3 PWM for RGB LED can be used through TCPWM
- Few GPIO for button and other IC
These generally mean that for high volume production where each penny is matter the implementation of this project
on PSoC4100 will provide a lot of saving and obvious increase the total income.
This was the main reason why I will plan to use 24MHz and no any UDB on the PSoC4200.
Figure 3. The main difference between PSoC4200 and PSoC4100
Part 3.2
As it was pointed in figure 2. I planning to use 1.5V AA battery. The ordered battery holder include the DC to DC Step Up regulator at 5V.
Now I am planning to create only the prototype for this "PSoC 4 Smarter Life Design Challenge" and not the final production PCB in super duper tiny design, mainly because I have not get any offer from shoe manufacturer yet ))), but also because of short time which I have before the dead line. It is good to see how some of the shoe manufacturer will react to this implementation but also as DAB was mentioned there maybe other companies who will willing to create that design and go out to the market. I will be here for offers )))
So to come back to the theme I am saying that based on the extracted image of the PSoC 4 Pioneer Kit we can see that it has internal regulator at 3.3V as it show the below figure 4.
These will be a source of power for all components on the circuit including the Bluetooth module which may operate in 2.9V to 3.4V
Figure 4. Block diagram of PSoC 4 Pioneer Kit.
That's it for today.
See you soon )
Day 4.
Continue the power consumption calculation for the maximum possible current peak of each component. This based on the original datasheet specs.
I have the below figures:
The Sensors board include the following there sensors: MPU6050 + HMC5883L + MS5611
1. The MPU6050 which is 3-axis Gyroscope with 3-axis Accelerometer required 3.8mA (I will not use internal DMP so it will be disabled, but even if it will be enabled the total current consumption will be 3.9mA)
So this 3.8mA value is for both Gyro + Accel Enabled.
2. The HMC5883L which is 3-axis Magnetometer consume 100uA=0.1mA in normal mode and 2uA in idle. Sounds good.
3. The MS5611 which is Barometric Pressure Sensor with Temperature Sensor consume 1uA, but have maximum peak current of 1.4mA during conversion.
4. The Bluetooth module BTM180 generally after transmission with connected wireless link consume 6mA.
In standard data exchange the value is approximately 15mA.
But for the worst case scenario I have to consider the spec from datasheet which mention value of 58mA after reset, while in practice is ~ 20mA
If link will be closed then the module can go to deep sleep with 40uA. But in practice I want to see how often I will wake up the module for data transmission.
I need to decide what will be better for friendly functionality of the project: the often data update through Bluetooth link or Once update for instance per second with large buffer of all captured data during 1sec.
This will be described in other day. So do not worry about it. Today is power consumption day.
5. The PSoC4100/PSoC4200 with 24MHz and code execution from Flash consume 7.2mA
6. Cypress Internal OpAmp 1mA or 10mA. I will go for 1mA in settings option, because I just need it for buffer before ADC.
7. Cypress Internal SAR ADC 1mA.
8. For the FSR resistor even if we assume from some M Ohm it will goes to 0 Ohm which will not happen, but any way.
So If I will use for the RM resistor a value for instance of 10K then this will give me 3.3V/10KOhm=0.00033A= 0.33mA
9. RGB LED each have R values: 2K2, 1K5, 1K5. So this will give me 3.3V/2K2=1.5mA for Red, 3.3V=1K5=2.2mA for Green and 2.2mA for Blue
10. PullUp resistor on I2C bus for incstance 2K2, but in circuit is higher so I will go for worst scenario of 2K2. So 3.3V/2K2=1.5mA for SDA, and 1.5mA for SCL.
This obviously will be in high state but need to consider all worst cases as possible.
So let do the summary:
3.8mA + 0.1mA + 1.4mA + 58mA + 7.2mA + 1mA + 1mA + 0.33mA + 1.5mA + 2.2mA + 2.2mA + 1.5mA + 1.5mA = 81.73mA
So the maximum possible current leak maybe 81.73mA, the DC to DC from 1.5V to 5V from spec mention that it can output 100mA so this mean we are in the game.
Obviously the design will be constructed in order to use all components in much smaller power mode as possible for proper longer operation from battery source.
Finally because the PSoC 4 Pioneer Kit include PSoC5 and many other circuits the current leak will be obviously higher than 81.73mA
For this reason the development and debug will be run through USB and by full completion of the software I will disconnect the PSoC 4 Pioneer Kit and will use this custom SSOP28 adapter in figure 5 with 28pin SSOP MCU.
Figure 5. SSOP 28 DIP adapter
By doing that I will manage to be in proper current specs of maximum 81.73mA because no other current leak will be in the circuit.
The above SSOP28 DIP Adapter was also ordered in the same day from here: Cool Components SSOP to DIP Adapter 28-Pin
The single chip MCU CY8C4245PVI-482 was also ordered with the Development Kit at same day from here: CY8C4245PVI-482 - CYPRESS SEMICONDUCTOR - PSOC4, CORTEX-M0, 28SSOP | Farnell UK
Finally if some one ask where is the regulator from 5V to 3.3V for that DIP adapter approach the answer is simple the sensors board include 150mA 3.3V LDO. This LDO I will use:
The schematic of the sensor board is showing in the below figure 6 and both side of that PCB showing in the figures 7a and 7b.
Figure 6. Schematic of Sensors board
Figure 7a. Top view of Sensors PCB Figure 7b. Bottom view of Sensors PCB
That's it for today.
See you soon )
Day 5.
Few days ago received the PSoC 4 Pioneer Kit and start the embedded development.
Today I will show you step by step the internal components implementation on PSoC4.
The figure 8 is present the schematic of this project. The advantage of this implementation as it was mentioned before
is to make it work on both PSoC4100 and PSoC4200 because no any of the 4 UDB was required.
Figure 8. The Schematic on PSoC4
The pins map for TQFP44 and SSOP28 are presented in figure 9 and figure 10 accordingly. As you can see the UART_1 moved it pins from P0_4 -> P3_0 and P0_5 -> P3_1 and also
the Pin_LED_Red from P1_6 -> P0_6. This is because PSoC 4 Pioneer Kit have the Red led pin on P1_6 and the UART pins on P3_0 with P3_1 was used between PSoC5LP.
So for custom PCB using board from above figure 5 the pins map can be used as it show the below figure 10.
Figure 9. The TQFP44 pins map for PSoC4200 on the PSoC 4 Pioneer Kit.
Figure 10. The pins map for PSoC4100 CY8C4125PVI-482.
As you can see the total size of used Flash and SRAM with settings for ARM GCC Compiler 4.7.3 and optimization option -Os (Size) and newlib-nano enabled gives below result:
Flash used: 1294 of 32768 bytes (3.9 %).
SRAM used: 1532 of 4096 bytes (37.4 %).
The increased size of SRAM is because by default the heap size and stack size was set to be 0x0100 and 0x0400 accordingly as it show the below figure 11. This will required 0x0500 = 1280 bytes. The rest of couple of hundred bytes was need for the PSoC4 library.
Figure 11. PSoC4 system settings.
The analog map is showing in figure 12 below:
Figure 12. PSoC4 analog in PSoC4100.
The clock settings is showing in the below figure 13. The UART for Bluetooth module use 115200 baud rate. The 3 TCPWM for RGB LED 1MHz with 10000 step for overflow which gives 100Hz refresh rate. The intensity of the light led is adjusted by the compare value. This is very critical for having long battery life instead of just using the single three GPIO for LED. By switch the LED power in 100Hz with custom duty cycle is possible to save more energy from x2 if (duty cycle is 50% to x10 or x100 if continue to reduce the duty cycle.
The next clock is for default standard I2C data rate of 100Kbps. Finally the analog part used for 12bit SAR ADC clock of 4MHz.
Figure 13. Clocks on PSoC4.
Last but not least for today I want to show the all used interrupts in the PSoC4 as it show the below figure 14.
Figure 14. All Interrupts which available in this project
More description about schematic will be done in next day.
See you soon )
Day 6.
Before I will move to the source code description I want to complete with settings for the PSoC4 as it show the figure 8 but also the main system clocks as well.
Starting from the main system clocks I have setup it as it show the below figure:
For Analog Circuit for FSR sensor I have below components:
The Pin_FSR_PowerSupply is used as a power supply for FSR and was set as: Digital Output with Strong Drive and fast Slew Rate etc
The Pin_FSR is Analog input and was set as: Analog in Type tab and High Impedance Analog in General
The Opamp was set as:
The ADC was set to 11-bit resolution as:
For Button Interface I used:
The isr_Pin_Button was set as Derived:
The Pin_Button was set as: Digital Input, Resistive Pull Up and Initial state High, in input tab the Interrupt was set to Falling Edge.
For Interface for GY-86 PCB with 3-axis Accelerometer + 3-axis Gyroscope + 3-axis Magnetometer + Barometer/Altimeter + Temperature sensors
The I2C_1 was set as it show below figure, if higher Date rate will need then 100Kbps can be changed to 400Kbps very easy:
The Pin_GY86_DRDY was set as: Digital Input, Resistive Pull Down with Low value and Rising Edge in interrupt option
The isr_Pin_GY86_DRDY was set as: Derived
The Pin_GY86_INTA was set as: Digital Input, High Impedance Digital, Low initial state, Interrupt None
For BX10 Bluetooth module interface I used:
The UART_1 was set as:
The Pin_BX10_PIOx were set as: Digital Input, Strong Drive with low state and Fast Slew rate.
For RGB LED Interface I used:
The PWM_x were set as, but obviously the Compare value is changing programmable for high and low intensity from 5000 to 10000 value.
The isr_PWM_x was set as: Derived
The Pin_LED_x was set as: Digital Output with HW Connection and Output Enable, Strong Drive initial state High and Fast Slew rate.
The Pin_RGB_Control was set as: Bidirectional, Strong Drive with High initial state and Fast Slew rate.
That's it for today.
See you soon )
Day 7.
Last week I complete the library for GY-86 and test all the hardware apart from GY-86 which left for the last hardware block.
The sensors library integrate also sensors fusion algorithm for different error compensation and also use quaternions which not suffer from "Gimbal lock" because use 4 dimension orientation instead of 3.
The PSoC4 also calculate the Pitch,Roll and Yaw and offload the external device such as mobile phone to do all sort of calculation which 32bit Cortex-M0 easy able to do it.
Everything seems to be fine, but when I start working with received GY-86 PCB from ebay I was unlucky to manage to communicate with MS5611.
I attached the snapshot from logic analyzer and as you can see I am not getting ACK from the device.
I tried many different senarios such as power up it from separate LDO regulator, trigger SCL line multiple times for unlock the possible freeze on SDA and some other tricks but the IC MS5611 is not respond.
I decide to change 2K2 resistor to 4K7 and also unsolder the dual MOSFET and bridge properly the SCL and SDA but again no any light.
Just thinking to unsolder the MS5611 from the board to see if I can at least to communicate with MPU6050 which this also do not reply. The only IC which seems to work on the board is HMC5883 which gives the DDRY output.
So here in figure 15 is the problem with ACK which I am not getting it.
Figure 15. MS5611 no ACK.
If I will have a luck and the GY-86 will work without the MS5611 sensor then I will upload the project and photos with video.
Day 8.
After identification of the problem with GY-86 PCB for which I lose few days. Finally want to report that this PCB works fine, but SCL and SDA pins are flipped, so be careful )
The source code of PSoC4 "Bluetooth-Enabled Smart Shoe" is completed successfully! )))
I also updated the I2C bus rate from standard of 100kbps to 400kbps which optimized for the performance.
The source code was used all 100% from the MCU Flash memory as you can see from the below image 16.
Figure 16. The PSoC4 32KB Flash was used 100% )))
This project for PSoC4 Smart Life Challenge include many new novelties. Below you can find in attachment the full source code.
The integrated Sensor Fusion Algorithm can be used in many other projects for orientation,navigation and etc and will not suffer from Gimbal lock because algorithm in PSoC4 use quaternions.
The library for MPU6050, HMC5883 and MS5611 is ready for all of you. The hardest work I done for you already )
The Bluetooth communication is work smoothly and I fully tested that as well as you will see in the video below.
The device send out data only after receiving 'A' or 'H' characters by Bluetooth link. If 'A' character will receive it send out by Bluetooth the ASCII strings with all sensor data and calculated values, if 'H' receive it send a compact HEX data packet utilizing union of the C language.
This project also utilized the STOP mode which consume just 20nA. The power source is just 1.5V battery. )
Using the single button you can wake up the device from STOP mode and then by pressing it second time you will make the Bluetooth module Discoverable, so the RFCOMM / SPP link can be occur.
I am very happy that in this 3 weeks time I completed, so large amount of work in order to make this project to work and not only that, but the quality of the result you will see from the source code as well.
I think this is really great prototype design which can be easy converted to a commercial product. Who knows maybe in few months or years you will see that product on the market )
The idea for this project was based from the Cypress and I extend it with support of FSR sensor. So I would like to acknowledge the Cypress for this initial idea!
I decided to participate in this contest because I like the real competition and maybe you already know that I was one of the winner in PSoC5 contest in 2011 )
Let see what judges decide )
And good luck to others as well! )
Here we go. This is a prototype image on figure 17 of my project.
Figure 17. Prototype of the Bluetooth-Enabled Smart Shoe.
This is the demonstration of Bluetooth connectivity with PC through RFCOMM link where you can see how ASCII and HEX mode are works with transmission of all sensors data and calculated values for quaternions, Pitch, Roll and Yaw and Euler Angles as well. Plus this FSR value which is reading through SAR ADC, which changing from 0 value to higher numbers when I pressing the sensor area.
The below second video present the operation of Bluetooth-Enabled Smart Shoe with an Android mobile phone and the freeware app "S2 Terminal for Bluetooth Free" which can be downloaded from here https://play.google.com/store/apps/details?id=jp.side2.apps.btterm&hl=en
The below video present the C# PC GUI interface which receive all HEX data by Bluetooth module which send the prototype board and display them on the according boxes and graphical axis.
Thank you for looking on this project.
I hope you found it interesting and useful by having the available full source code below.
Kind Regards,
Anastasios