Reading MAX30100 (heart beat sensor) Data From I2C Bus And display with LED or other devices using bascom codes

Go To Last Post
19 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi guys

I need Help About Using I2C bus To read Data From a MAX30100  heartbeat sensor using Attiny13 or Attiny2313 and Display the sensing data with LED or other devices.

also i need that codes for use in bascom

Thank you 

Last Edited: Fri. Oct 12, 2018 - 07:53 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I take it you have read:

 

https://avrhelp.mcselec.com/conf...

 

EDIT: ah sorry, just realised you said you picked the wrong AVR for doing I2C and are using Tiny which may only have USI. In which case you probably need to read this instead:

 

https://avrhelp.mcselec.com/usin...

Last Edited: Thu. Oct 11, 2018 - 10:56 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi thank you
I'll read them

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

See my edit. because you picked the wrong AVR you may only have USI not real TWI/I2C.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I were saw people using arduino to read i2c data from max30100 and display on lcd but I use to make my project without using arduino or any computer

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I want to use a sensor with a avr chip and some led or miniator vibrating electromotor
And also the main bascom codes for programing avr

Last Edited: Thu. Oct 11, 2018 - 11:04 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It disent matter for to use wich one of avr chips but I want use a small one with 8 pins or max 20 pins

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If you want to use I2C why not pick an AVR that has I2C (aka TWI) in it? 

 

What is the appeal of using a Tiny when they don't have a TWI peripheral (as the 328 on an Arduino does!)?

 

The two Tiny chips that have TWI are:

C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr>grep TWCR iotn*
iotn48.h:#define TWCR _SFR_MEM8(0xBC)
iotn88.h:#define TWCR _SFR_MEM8(0xBC)

C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr>

that is Tin4y8 and Tiny88 but these are 28 pin chips (but very small in packages such as QFP / QFN).

Last Edited: Thu. Oct 11, 2018 - 11:08 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I were study about i2c protocols and the right connections and wiring to sda and scl pins
But I have problem about the righ codes in bascom to get data from scl and sda who generated by my sensor.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

As I say, the chips you picked have USI not TWI. But as the Bascom help for USI (second link in post #2) shows the USI can do I2C under control from Bascom.

Last Edited: Thu. Oct 11, 2018 - 11:11 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

My question is
Why I cant use an avr chip that has i2c capability
And have to use twi?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ok
Can you please write some codes about my goal ?
Bascome codes

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

navan-123 wrote:
Can you please write some codes about my goal ?

If you make an offer for EUR60/hour you may be able to find someone to write the code for you.

 

But basic is not a popular language, at least here on avrfreaks.

Github also has almost no response for "bascom":

https://github.com/search?q=bascom

 

A search on github for the max30100 gives plenty of results, but all are probably in C / C++ and written for "arduino"

https://github.com/search?q=max30100

 

You may want to consider to dive into the "arduino" world.

All development tools are free, and you can buy PCB's for a few EUR.

Easy boards to start with are the "arduino nano" or "arduino micro":

https://www.aliexpress.com/w/wholesale-arduino-nano.html

 

The "openlog" boards are probably among the smallest boards with an ATMEGA328. But I'm not sure if these have the arduino bootloader, so you may need an external programmer for these.

https://www.aliexpress.com/wholesale?catId=0&initiative_id=SB_20181011033217&SearchText=openlog

 

I'd recommend the ATMEGA328 (or ATMEGA 168) as it is the de facto standard for AVR development and used in all of the above boards.

With the above boards you can start tinkering on a breadboard, or solder some wires between the boards to make something more compact.

The QFP package is reasonably easy to solder by hand (on a PCB where it fits) and an 32pin QFP is about similar in size (but a lot thinner) then a 8 pin DIP.

 

USI is a nuisance.

Paul van der Hoeven.
Bunch of old projects with AVR's:
http://www.hoevendesign.com

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

navan-123 wrote:
Why I cant use an avr chip that has i2c capability And have to use twi?
Well it's your call. I2C involves driving wires with a specific protocol while you could just do that using two open collector output IO lines it would be quite a lot of work to make it function OK. The next best option, if all you have is a Tiny, is to use USI. It's not a complete I2C implementation but it does help a bit with some of the work but you still require quite a lot of supporting code (though if you are lucky bascom may provide some of this). Then there is the real TWI/I2C peripheral found in most "Mega" AVR chips. This handles most of the work so the software you need to provide is simpler and reduced further. So it's your choice.

 

It just seems an odd choice to me to center a project around an I2C peripheral and then not choose a micro that has real I2C to connect to it. You are simply making more work for yourself.

 

However, maybe Bascom does do some of the work for you? As there aren't many people using Bascom here that question is probably best directed to the Bascom support forum: https://www.mcselec.com/index.ph...

Last Edited: Thu. Oct 11, 2018 - 12:39 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thank you so much my friend for your attention.
I will do my best.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

navan-123 wrote:
My question is Why I cant use an avr chip that has i2c capability And have to use twi?

 

TWI and I2C are the same thing.

 

I2C is a trademark owned by Philips/NXP. TWI is a trademark owned by Atmel/Microchip.

 

Electrically they are the same thing.

#1 This forum helps those that help themselves

#2 All grounds are not created equal

#3 How have you proved that your chip is running at xxMHz?

#4 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand." - Heater's ex-boss

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

There may be some small differences between implementations of I2C and TWI, but most of it is legal mumbo jumbo that no normal people care about.

One of the differences may be the support for clock stretching, or may be when you try to use exotic modes such as mutli master, which is not often used.

I2C and (often ?) TWI outputs are slew rate limited, which can be quite important to reduce generated noise, especially in mixed analog & digital circuits.

If you're interested in differences, do some reading:

https://duckduckgo.com/?q=i2c+twi+trademark

 

According to the link below the I2C trademark expired in 2014.

https://trademarks.justia.com/770/06/i2c-77006370.html

 

I2C / TWI seems very simple from the outside ( just 2 wires with pullup resistors,) but the specifications are quite complex and a lot of exceptions must be handled for a robust firmware stack.

But if you use an existing (high quality) library you probably do not have to wory about that too much, especially if you only have a uC and a single other IC on the bus.

 

A variant of I2C is "SMBUS". SMBUS adds a minimum clock frequency and some other timing constraints to ensure that the bus can not stay in a state where further communication becomes impossible (An oversight in the I2C spec).

Paul van der Hoeven.
Bunch of old projects with AVR's:
http://www.hoevendesign.com

Last Edited: Thu. Oct 11, 2018 - 11:32 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The Max30100 is a very interesting chip!

 

Note that it has a Vcc of 2 Volts!!!

Read the data sheet carefully as you interface it to your micro, which is likely running at 3 or 5 V.

 

As others stated, pick a micro that makes this project somewhat easier to do, i.e. one that has an I2C hardware interface.

Writing your own I2C interface, and using a general purpose I/O pin to mimic an open-collector output is doable, but rather tricky if you don't have a fair amount of experience.

 

There are many examples of using the Max30100 with an Arduino Uno.

I'd purchase an Arduino Uno for Banggood Electronics for a couple $USD, hook up the wires, download a known good program, and see the chip work.

 

I'd then study the data sheet and the known good working code and write the program in Bascom.

 

Once that worked, I'd consider re-writing it for a different / smaller chip, if there was some incredibly good reason to do so.

 

There are also simpler I2C chips available, and perhaps a good starting point would be to interface a character LCD with an I2C interface, or a digital temperature chip with an I2C interface, etc., so that you can learn how the I2C hardware and software work.  Then apply that knowledge to the Max30100.  Learn to walk before you run.

 

The usual way the Freaks forum works is that you post your code, and you get some feedback and suggestions in how to make it work, or work better.

 

Just saying give me the code (program) and expecting a full working solution isn't likely to get you very far.

 

There are a number of Bascom projects both on the Bascom Forum's site, and on the web, but a quick search didn't show one for the Max30100.

 

So, in summary:

 

Hook your Max30100 up to an Arduino Uno and verify that the hardware works using one of the many working Arduino programs on the web for this chip.

 

Study the working program and convert it to Bascom.

 

Look at some Bascom I2C examples to help understand the big picture.

 

JC

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks man
I just want a simple right code to get data from max30100 with i2c bus. Not the full program. I have knowledge about the diffrence between twi and i2c and etc but I have to use simple components not an arduino. I want to use the right guidence to develope my program.
Thanks again.