Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

library integration on ESP32 #66

Open
micfuc opened this issue Nov 20, 2018 · 43 comments
Open

library integration on ESP32 #66

micfuc opened this issue Nov 20, 2018 · 43 comments

Comments

@micfuc
Copy link

micfuc commented Nov 20, 2018

Hi , I am integrating Si5351Arduino on an ESP32 micro using arduino IDE.
I get erratic behaveures when using the set_freq and set_freq_manual methods; in particular:

  1. the status is always as following
    SYS_INIT: 1 LOL_A: 1 LOL_B: 1 LOS: 1 REVID: 0
  2. when setting more then one CLK with set_freq no out is generated; with a single clk it works
  3. when setting frequencies > 10 Mhz the actual value obtained is completely wrong
  4. by using the set_freq_manual it works pretty good on a single clock
  5. by using the set_freq_manual with 2 or 3 clocks does not work...

can you please help to fix these issues ?

Thanks in advance for any help and thanks for the wonderfull work done ...

Mike

@NT7S
Copy link
Member

NT7S commented Dec 18, 2018

I recently acquired an ESP32, so at some point I should be able to look at this, but right now I'm in the middle of a crunch to get some other projects shipped, so this will have to wait a bit. Thanks for the report.

@paulh002
Copy link

paulh002 commented Jul 3, 2019

I have exactly the same issue. I now use a interface developed by JF3HZB maybe there is some timing issue

@WA2FZW
Copy link

WA2FZW commented Aug 15, 2019

Me three! I just reported this to Jason directly yesterday. Unlike Mike, however, when I look at the status bits, they all look good! The program I'm trying to make work is the "si5351_calibration" program from the examples that come with Jason's library. The only mods I've made to it (other than a million different approaches to trying to make it work) was to actually read the frequency and PLL frequencies from the Si5351 to display them instead of just displaying what the program thinks they are.

I can also confirm that the JF3HZB software works as I have a modified version of his VFO working, and if I could figure out how to add the calibration function to it, I would!

John

@WA2FZW
Copy link

WA2FZW commented Aug 15, 2019

I tried the "si5351.set_freq_manual" function this morning - didn't help! Also tried different frequencies (5MHz, 10MHz and 15MHz) - Still just get a short burst of output then the Si5351 stops outputting. I'm only using CLK0 and PLLA, again in a slightly modified version of Jason's calibration program.

The output I get is:

Si5351 Calibration Program
Waiting for Si5351 to come online!

Si5351 is online!

I2C Bus Speed: 100,000.00 Hz
Actual correction: 0.00 Hz // Have this commented out
Target Frequency: 15,000,000.00 Hz // What the program thinks
Actual clock freq: 15,000,000.00 Hz // What the chip thinks
PLL-A Frequency: 800,000,000.00 Hz // What the chip thinks
PLL-B Frequency: 800,000,000.00 Hz // What the chip thinks

SYS_INIT: 0 LOL_A: 0 LOL_B: 0 LOS: 0 REVID: 0

Adjust until your frequency counter reads as close to 10 MHz as possible.
Press 'q' when complete.
Up: r t y u i o p
Down: f g h j k l ;
Hz: 0.01 0.1 1 10 100 1K 10k

Everything except "Target Frequency" is actually being read out of the chip.

And BTW, I'm using an Adafruit board; I see no significant electrical difference between the Adafruit board and the Etherkit board.

The current version of my code is attached (change the extension from "txt" to "ino"). It is set up to work on non-standard I2C pins; it doesn't work on the standard ones either! Comment out the "Wire.begin" call to use the default pins.

Si5351_Cal_With_Alternate_I2C.txt

John

@WanderLG
Copy link

WanderLG commented Sep 10, 2019

Most likely the problem is in the ESP32 Wire library, because using a logical parser, we can see that ESP32 loses I2C SCL sync.
I am sending 2 files with si5351_calibration.ino i2c logical data
Arduino vs ESP32

If you want to verify both files, download the Saleae Software.
https://www.saleae.com/pt/downloads/

The 2 files are here.
Analyzer Logic.zip

Muito provavelmente o problema é na biblioteca Wire do ESP32, pois usando um analisador logico, podemos perceber que o ESP32 perde o sincronismo SCL do I2C.
Estou enviando 2 arquivos com os dados lógicos i2c do si5351_calibration.ino
Arduino vs ESP32

Se quiserem verificar os dois arquivos, baixem o Software Saleae.
https://www.saleae.com/pt/downloads/

Os 2 arquivos estão aqui.
Analyzer Logic.zip

@WA2FZW
Copy link

WA2FZW commented Sep 10, 2019 via email

@WanderLG
Copy link

But something is happening and the package is getting lost.
look at these two comparisons.

This picture is the wire scanning for addresses. This one works perfectly.
Scan

and this is si5351_calibration.ino This does not work..

Cal

@WanderLG
Copy link

The two photos are just the end of the package. In the first photo, both work, but in the second photo, Arduino Works and ESP32 does not work.

@WA2FZW
Copy link

WA2FZW commented Sep 10, 2019

Oh, I agree something isn't working; just not sure what! You didn't say, but is the scanner program using the Wire library or not?

I definitely see some differences in the data streams in the 2nd set of pictures, but I'm not sure what they mean. There are a couple of strange pulses on the SCL line also:

image-1

John
WA2FZW

@WanderLG
Copy link

WanderLG commented Sep 10, 2019 via email

@WA2FZW
Copy link

WA2FZW commented Sep 10, 2019 via email

@WA2FZW
Copy link

WA2FZW commented Sep 10, 2019

This didn't seem to get posted when I replied via email:

Well, again, that would lead me to believe the problem is not in the Wire library, but in the Etherkit library. Again I am using the Wire library to communicate with a PCF8574 over the I2C bus with no problem, which would also lead me to believe the Wire library is OK.

John
WA2FZW

@ramapcsx2
Copy link

Hey,
the problem could be in the I2C implementation in the Si5351 chip itself.
I2C features like clock stretching could be used and this is known to cause issues with the ESP32 in particular.
So I recommend investigating for I2C protocol errors.
Check active and closed issues on the esp32-arduino project such as this one: espressif/arduino-esp32#2301

Good luck!

@WanderLG
Copy link

This is where the first error occurs.
Note that using Arduino, we have between 16+ACK up to 12+ACK 9 high SCL pulses.

But using ESP32 that doesn't happen and we only have 5 high pulses in SCL.

erro1

Jhon, I suspect the problem is with ESP32 i2c libraries as there are more people with this same problem using other i2c modules. Already the (JF3HZB) VFO works, because it built i2c communication without using the ESP32 specific libraries. It's not just Wire.h or Wire.cpp. There are others that are related.

@WanderLG
Copy link

But yes, there may be a way to work around this in the Etherkit SI5351 library without having to touch the ESP32 i2c libraries. I just don't know how to do this. But I'll try, if I can before you, post the result.

Note: I am Brazilian and do not speak English. I'm using google translator.
Wander. (PU4WLG)

@WanderLG
Copy link

There are people saying that they solved the ESP32 i2c problem by updating the package.

https://github.com/espressif/arduino-esp32/releases

Now I have no way to test this. But as soon as I get home, I'll take the test.

@WA2FZW
Copy link

WA2FZW commented Sep 10, 2019

That would be great! Let us know if it works! And tell me how to go about doing the update! I couldn't figure it out! Thanks!

John WA2FZW

@WanderLG
Copy link

I couldn't make it work. Updated to:
ESP32 Arduino 1.0.3 RC3 (IDF 3.2)
But still the error continues.
To generate frequency in only one output, CLK0 for example.
The JF3HZB / T.UEBO library works perfectly.
But it's manual so I don't know if it's possible to generate 3 independent outputs, like in this Jason Milldrum library.

VFO JF3HZB
https://onedrive.live.com/?authkey=%21APjYCcc%2DZzSw%2DCQ&id=567BE007779244E3%21101672&cid=567BE007779244E3

@WA2FZW
Copy link

WA2FZW commented Sep 11, 2019 via email

@WanderLG
Copy link

Jhon Thank you. I sent the email. Did it get there?

@WA2FZW
Copy link

WA2FZW commented Sep 11, 2019 via email

@paulh002
Copy link

paulh002 commented Mar 24, 2020

I have replaced the wire library by direct sending the i2c commands on the GPIO so called bit banging. Now it looks it works also on ESP32. You have to replace all the wire stuff. But thats relative simple. Did not test everything but for my application it is working. Code can be found on https://github.com/paulh002/VFO-ESP32-Si5351

@kd2eat
Copy link

kd2eat commented Jul 22, 2020

I can confirm that there is still a Wire library problem on ESP32 with version 1.0.4 for Arduino. I can't even get the basic Etherkit test programs to run.

I grabbed Paul's i2c and si5351 libraries above and was able to get test programs running. I'm going to move forward with my own code, which uses the VCXO. Paul, if I find glitches I'll post to your github.

Hopefully, Espressif will figure out their issue and fix their stock i2c implementation.

@NT7S
Copy link
Member

NT7S commented Jul 22, 2020

FWIW, I've ordered an ESP32 board so I can see what's going on for myself. If it is down to the Wire implementation for the ESP32 support package, I'll close this issue. However, I'd like this library to be as universal as possible, so it's long past time for me acquire an ESP32 board and make sure it can work.

@kd2eat
Copy link

kd2eat commented Jul 22, 2020

Awesome! Thanks for your great work with this library, BTW, I've used it for several little projects and it works like a champ. I've got a Logic analyzer and a pile of different model Arduinos and a few ESPs. If I get motivated to take a stab at things, I'll let you know. Also, if you need a test dummy, I'd love to give back for all your hard work. Just let me know if I can help.

@paulh002
Copy link

Some people got it working without an issue, so there is some variation. Maybe if you combine it with an ili9341 spi interface the i2c gets in problems. Anyway I also added multi si5351 support. Would be a nice extension to the library. This to lower the crosstalk between channels.

@vk4hat
Copy link

vk4hat commented Dec 24, 2020

The problem is something within the etherkit library, I never used to have this problem until i moved to platformio. My arduino implementation of ESP32 was old, very old and it worked flawlessly. But on anything new it fails. I have gone hunting for the issue but cant find it.

I have other libraries for SI5351 that do work with ESP32 the one from adafruit and there is one by Pavel Milanes that works flawlessly, so my guess is that there is something not right in how the etherkit library is talking over I2C.

SI5351 is the only thing I have issues with over I2C i have 2 LCD's a RTC and a couple of Port Expanders all hanging off I2C and they work fine, do its not the Wire library, but something in how the etherkit library is talking to the I2C, something is getting lost somewhere.

My problem is I needed quadrature output and Jason's library for that does not work with ESP32 and all my protoboards have ESP32 LOL, Yeah i can bust out the flopflops, but that cuts my frequency by 4 and I was working on a 2m implementation HAHA.

Keep up the good work Jason, you rock and I do not mean my post to sound critical of you, it works perfectly with ATmega, but something weird with esp32.

@paulh002
Copy link

paulh002 commented Dec 24, 2020 via email

@vk4hat
Copy link

vk4hat commented Dec 24, 2020

Hi Rob, in stead of moving to an other library, I changed the i2c part of etherkit. I also changed it to support multiple si5351's. You can get the code if you like on my github page. paulh002 By the way, I could not give comments to your blog, I think there is some issue 73 Paul Op do 24 dec. 2020 06:11 schreef vk4hat [email protected]:

The problem is something within the etherkit library, I never used to have this problem until i moved to platformio. My arduino implementation of ESP32 was old, very old and it worked flawlessly. But on anything new it fails. I have gone hunting for the issue but cant find it. I have other libraries for SI5351 that do work with ESP32 the one from adafruit and there is one by Pavel Milanes that works flawlessly, so my guess is that there is something not right in how the etherkit library is talking over I2C. — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#66 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIOBYUFVQYAYEJ6JN3LMCATSWLEQFANCNFSM4GFIYFOQ .

Thanks Paul, I will grab your code later and see if I can manage to make the quadrature SI5351 work with it. I did fix the comments on my blog, seems Jetpack changed settings and made people login with facebook or google to comment. That might explain why i have not had comments in a long time and no one let me know LOL

Cheers Mate

@Hi-Tone
Copy link

Hi-Tone commented Jan 25, 2021

I have a similar issue with this library (and all others who've contributed) and the ESP32. I've tried the Si5351_Cal_With_Alternate_I2C sketch by WA2FZW and I get an "Si5351 is online", however no frequency output.
I've tried the Adafruit library and that works out of the box, however it not very beneficial, so I am eager to get this one working.

I've looked into the I2C issues, however I've tried with all the sketches by various people commenting on this topic, and none of them gets me any output. In any case, working with ESP32, I always have to use:
#define SDA 23
#define SCL 22

If I don't use these, together with Wire.begin(SDA, SCL); my i2c never works with any module or sensor.

My setup is PlatformIO on VScode, NodeMCU-32s and an Adafruit module (I probably would have bought the Etherkit if I was aware of it before buying the Adafruit SI5351). I am measuring my output on a Agilent 53131A.

@vk4hat
Copy link

vk4hat commented Jan 26, 2021

I have a similar issue with this library (and all others who've contributed) and the ESP32. I've tried the Si5351_Cal_With_Alternate_I2C sketch by WA2FZW and I get an "Si5351 is online", however no frequency output.
I've tried the Adafruit library and that works out of the box, however it not very beneficial, so I am eager to get this one working.

I've looked into the I2C issues, however I've tried with all the sketches by various people commenting on this topic, and none of them gets me any output. In any case, working with ESP32, I always have to use:
#define SDA 23
#define SCL 22

If I don't use these, together with Wire.begin(SDA, SCL); my i2c never works with any module or sensor.

My setup is PlatformIO on VScode, NodeMCU-32s and an Adafruit module (I probably would have bought the Etherkit if I was aware of it before buying the Adafruit SI5351). I am measuring my output on a Agilent 53131A.

https://github.com/pavelmc/Si5351mcu This library does work with ESP32 out of the box. Its limited to 2 clocks only though. There is also a Russian\Ukrainian library that works as well, but dont have a link handy.

@Hi-Tone
Copy link

Hi-Tone commented Jan 26, 2021

I got it somewhat working now. I used the library by pavelmc and by setting the standard I2C pins for ESP32 (SCL - pin 22; SDA - pin 21). I used the simple example, however at 60 MHz I get close to 55 MHz output. At 112.5 MHz, I get 104 MHz output. Is it normal for it to deviate that much?
With the Adafruit library, I am able to get get 112.5 MHz by setting the 112.5MHz output.

PS: I tried afterwards the library from both Etherkit and WA2FZW. Both not working.

Update: I tried with an Arduino Uno I had laying around. I got it to work with the Etherkit example right away. Now I really would like it to work with the ESP32, because this proof that I can get the library working.

@NT7S If your still doing some testing on this library and are in need of testers, please let me know, I'm here to help.

@vk4hat
Copy link

vk4hat commented Jan 26, 2021

I got it somewhat working now. I used the library by pavelmc and by setting the standard I2C pins for ESP32 (SCL - pin 22; SDA - pin 21). I used the simple example, however at 60 MHz I get close to 55 MHz output. At 112.5 MHz, I get 104 MHz output. Is it normal for it to deviate that much?
With the Adafruit library, I am able to get get 112.5 MHz by setting the 112.5MHz output.

Reset the PPL's

@Hi-Tone
Copy link

Hi-Tone commented Jan 27, 2021

I assume you mean the PLL? In the library you attached by pavelmc, this is already done as standard.

@vk4hat
Copy link

vk4hat commented Jan 27, 2021

I assume you mean the PLL? In the library you attached by pavelmc, this is already done as standard.

If you are making a jump of more than a meg or so, it needs to be called again. I do not have any problem with it being inaccurate.

@kd2eat
Copy link

kd2eat commented Feb 15, 2021

Just an update on this problem. I tested the Etherkit library again with Espressif's Arduino esp32-1.0.5-rc6 build. Still no joy. The behavior seems about the same as with the 1.0.4 release. I was hoping the vendor lib's might fix it, since there have been updates in the wire code. Apparently not. :-(

I'm having a few minor issues with Paul's "bit-banging" library. It doesn't seem to play well if I'm using I2C via the Wire library on the same pins. I either have to figure out why, or redesign my riser board to bit-bang on a different pair of GPIO ports for using the Si5351. Paul's also doesn't seem to disable transmit when I call:
si5351.output_enable(OUTPUT_CLOCK, SI5351DISABLE);
I may dig into that and see if I can sort it out. That's actually more problematic than the Wire() conflict at the moment.

Anyway, I thought I'd share an update.
Mike

@paulh002
Copy link

Sharing the same ports with Wire can indeed be a problem, in my project I only have si5351's attached. The output_enable function I did not use. But i will check. It is a pity that the wire lib does not work, I tried to look into it did some analysis with my scope that can decode i2c but no luck. Cost too much time to debug this issue.

@kd2eat
Copy link

kd2eat commented Feb 15, 2021

Thanks Paul, I read through the code a bit last night and everything looked about right, though I didn't do any serious debugging. I was hoping it was something as simple as you hadn't implemented the routine and just stubbed it in.

I'll try to hook up my logic analyzer in the next few days to get a capture of the behavior. If you want to take this offline, since it's not really related to the etherkit library, feel free to contact me at kd2eat at gmail.com. Thanks for writing back :-)

@ghost
Copy link

ghost commented Jun 18, 2021

Here's what works for me:

In the SI5351::si5351_read method

Change
Wire.requestFrom(i2c_bus_addr, (uint8_t)1, (uint8_t)false);

to
Wire.requestFrom(i2c_bus_addr, (uint8_t)1);//, (uint8_t)false);

Arduino 1.8.13

ESP32 package 1.0.6

Windows 10

Regards,

Dave

@paulh002
Copy link

That would be great, will test it

@paulh002
Copy link

Here's what works for me:

In the SI5351::si5351_read method

Change Wire.requestFrom(i2c_bus_addr, (uint8_t)1, (uint8_t)false);

to Wire.requestFrom(i2c_bus_addr, (uint8_t)1);//, (uint8_t)false);

Arduino 1.8.13

ESP32 package 1.0.6

Windows 10

Regards,

Dave

I have tested this solution and it works good.
Thanks

@PE2BS
Copy link

PE2BS commented Nov 9, 2022

Thanks, works well. It was the solution for the problem with the ESP32 and the Si5351 board.
73
Ruud / PE2BS

@vk4hat
Copy link

vk4hat commented Nov 9, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants