It is currently 22 Oct 2018 10:54

All times are UTC + 1 hour




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: 10 Mar 2018 09:59 
Offline

Joined: 02 Feb 2018 14:49
Posts: 12
Location: Singapore
Hi guys, I am currently starting out on a project that I think might be able to lead somewhere purposeful some day. I have a project that requires me to think outside the box and to make use of various components from various makers/companies. In one of the portions of the project, I have worked up the need to interface a PIC18F26K20 with an INA219 breakout module by Adafruit.

As most of us are aware, the Adafruit INA219 has been created to be compatible with Arduino-supported development boards. So, I have been working with Arduino for a few years, knowing how to use the INA219 library has been like driving a car, I never had the reason or need to understand what happens underneath the hood when it comes to reading and writing those registers, reading values and so on.

But now, I have a need to build this custom integration between the PIC18F26K20 using mikroC and I am trying to crack my brains on how to establish the communication between the INA219 + my PIC on the EasyPIC v7. i am looking for any geeks or nerds who have a good idea how to adapt the INA219 library over to mikroC.

In the efforts of creating something like this, I intend to share the project within the "Examples" section of the mikroC environment as well. I like to contribute what I have learned and done with everyone within the community as well. I am pretty sure some people might find the application useful as well.

(Below) I am putting the library files side by side, hoping to figure out how to implement the read/writing of registers and getting the readings using I2C1_XX()
https://i.imgur.com/qvVfTwn.png <-- Sorry, high res image, so I attached as links

(Below) I am also going to put the library/code example under the Examples folder of mikroC.
https://i.imgur.com/ED0dqXz.png <-- Sorry, high res image, so I attached as links

Thanks again, I really appreciate it in advance, to anyone who can help me along. I have this weekend to figure this out.

_________________
cxshermansg
"I am always hacking at something, 24-7-265 days a year."/ "For some people, they have to be lucky all the time, but I only have to be lucky once." / "Keep trying and never give up until you succeed."


Top
 Profile  
 
PostPosted: 26 Mar 2018 18:49 
Offline

Joined: 02 Feb 2018 14:49
Posts: 12
Location: Singapore
Hey guys, so, a few weeks ago, I began working on the idea of integrating the Adafruit INA219 library to the mikroC development environment. I have been busy with a few other things lately but managed to test it out earlier tonight. I have used a video recording to document what has been done and also the values I have managed to retrieve from the INA219 breakout board. Base upon the video, you can see that I managed to retrieve the value of the current in mA. However, when trying to display it using the LCD, it seems to be in jibberish. I need to figure this portion out, so if anyone has any idea, I would really appreciate the help.

Here's the short 2 min 14 sec video I recorded using my phone:
https://drive.google.com/file/d/1c_kQkFojqusY56Ck4FC44LFC-dx0au5l/view?usp=sharing
(Sorry if the video file seems quite large (332MB) and it seems to take a long time to upload. Maybe if the forum administrators take my UX feedback to add the progress indicator, it might just feel a lot faster.)

Here's the source code that I created using mikroC PRO for PIC:
Attachment:
File comment: My source codes
INA219.zip [188.57 KiB]
Downloaded 46 times


I might've figured out how to get the USB UART connector to work. I just had to change the switch SW1.1 (RC7) & SW2.1 (RC6). I have yet to test the UART, going to do that next.

I really need to figure out the returned values and how to properly filter/trim/process the values so I only get for example "3.20" for the mA, and when I print my string to the LCD, it should be just strings...not sure why it is always jibberish. What I like to display on the LCD is the following:

Current: 3.20 (<-- only this value changes) mA


Not sure if this is possible. But I can also just print out the entire string again. (not that important)

Just to add to the UART portion of the program, I have been getting the following results:
Attachment:
UART-jibberish.jpg
UART-jibberish.jpg [ 115.06 KiB | Viewed 349 times ]

_________________
cxshermansg
"I am always hacking at something, 24-7-265 days a year."/ "For some people, they have to be lucky all the time, but I only have to be lucky once." / "Keep trying and never give up until you succeed."


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: