From 4df082cb4eb6659d76dd9a38988033c82c662fa9 Mon Sep 17 00:00:00 2001 From: Nick Foster Date: Tue, 5 Apr 2011 09:18:14 -0700 Subject: N210: implemented mboard sensors for ref lock and MIMO lock --- host/lib/usrp/usrp2/mboard_impl.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'host/lib/usrp/usrp2/mboard_impl.cpp') diff --git a/host/lib/usrp/usrp2/mboard_impl.cpp b/host/lib/usrp/usrp2/mboard_impl.cpp index 29e0535f8..520ee49a6 100644 --- a/host/lib/usrp/usrp2/mboard_impl.cpp +++ b/host/lib/usrp/usrp2/mboard_impl.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -362,11 +363,32 @@ void usrp2_mboard_impl::get(const wax::obj &key_, wax::obj &val){ case MBOARD_PROP_CLOCK_RATE: val = this->get_master_clock_freq(); return; + + case MBOARD_PROP_SENSOR: + if(key.name == "mimo_locked") { + val = sensor_value_t("MIMO", this->get_mimo_locked(), "locked", "unlocked"); + return; + } + else if(key.name == "ref_locked") { + val = sensor_value_t("Ref", this->get_ref_locked(), "locked", "unlocked"); + return; + } else { + UHD_THROW_PROP_GET_ERROR(); + } + break; default: UHD_THROW_PROP_GET_ERROR(); } } +bool usrp2_mboard_impl::get_mimo_locked(void) { + return bool((_iface->peek32(_iface->regs.irq_rb) & (1<<10)) > 0); +} + +bool usrp2_mboard_impl::get_ref_locked(void) { + return bool((_iface->peek32(_iface->regs.irq_rb) & (1<<11)) > 0); +} + /*********************************************************************** * MBoard Set Properties **********************************************************************/ -- cgit v1.2.3 From a4aa89ed5d73b6afa5d2d28d8f2b6cc206baf22d Mon Sep 17 00:00:00 2001 From: Nick Foster Date: Fri, 8 Apr 2011 14:59:46 -0700 Subject: USRP2: Added GPS time support to the sensors interface. gps_time sensor returns epoch time as time_t. Untested. --- host/include/uhd/usrp/gps_ctrl.hpp | 6 ++++++ host/lib/usrp/gps_ctrl.cpp | 4 ++++ host/lib/usrp/usrp2/mboard_impl.cpp | 6 +++++- 3 files changed, 15 insertions(+), 1 deletion(-) (limited to 'host/lib/usrp/usrp2/mboard_impl.cpp') diff --git a/host/include/uhd/usrp/gps_ctrl.hpp b/host/include/uhd/usrp/gps_ctrl.hpp index 21d400b3b..bd679b165 100644 --- a/host/include/uhd/usrp/gps_ctrl.hpp +++ b/host/include/uhd/usrp/gps_ctrl.hpp @@ -42,6 +42,12 @@ public: * \return current GPS time and date as boost::posix_time::ptime object */ virtual ptime get_time(void) = 0; + + /*! + * Get the epoch time (as time_t, which is int) + * \return current GPS time and date as time_t + */ + virtual time_t get_epoch_time(void) = 0; /*! * Tell you if there's a supported GPS connected or not diff --git a/host/lib/usrp/gps_ctrl.cpp b/host/lib/usrp/gps_ctrl.cpp index ff8e9cee6..ace56e7ed 100644 --- a/host/lib/usrp/gps_ctrl.cpp +++ b/host/lib/usrp/gps_ctrl.cpp @@ -172,6 +172,10 @@ public: } return now; } + + time_t get_epoch_time(void) { + return (get_time() - boost::posix_time::from_time_t(0)).total_seconds(); + } bool gps_detected(void) { return (gps_type != GPS_TYPE_NONE); diff --git a/host/lib/usrp/usrp2/mboard_impl.cpp b/host/lib/usrp/usrp2/mboard_impl.cpp index 520ee49a6..7a756087a 100644 --- a/host/lib/usrp/usrp2/mboard_impl.cpp +++ b/host/lib/usrp/usrp2/mboard_impl.cpp @@ -372,7 +372,11 @@ void usrp2_mboard_impl::get(const wax::obj &key_, wax::obj &val){ else if(key.name == "ref_locked") { val = sensor_value_t("Ref", this->get_ref_locked(), "locked", "unlocked"); return; - } else { + } + else if(key.name == "gps_time") { + val = sensor_value_t("GPS time", int(_gps_ctrl->get_epoch_time()), "seconds"); + } + else { UHD_THROW_PROP_GET_ERROR(); } break; -- cgit v1.2.3 From b31cefc5eb7022db4851ad333577b5b6829ca2db Mon Sep 17 00:00:00 2001 From: Nick Foster Date: Fri, 8 Apr 2011 15:07:28 -0700 Subject: USRP2: enable GPS by default --- host/lib/usrp/usrp2/mboard_impl.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'host/lib/usrp/usrp2/mboard_impl.cpp') diff --git a/host/lib/usrp/usrp2/mboard_impl.cpp b/host/lib/usrp/usrp2/mboard_impl.cpp index 7a756087a..42ba714a4 100644 --- a/host/lib/usrp/usrp2/mboard_impl.cpp +++ b/host/lib/usrp/usrp2/mboard_impl.cpp @@ -101,9 +101,9 @@ usrp2_mboard_impl::usrp2_mboard_impl( //contruct the interfaces to mboard perifs _clock_ctrl = usrp2_clock_ctrl::make(_iface); _codec_ctrl = usrp2_codec_ctrl::make(_iface); -// _gps_ctrl = gps_ctrl::make( -// _iface->get_gps_write_fn(), -// _iface->get_gps_read_fn()); + _gps_ctrl = gps_ctrl::make( + _iface->get_gps_write_fn(), + _iface->get_gps_read_fn()); //if(_gps_ctrl->gps_detected()) std::cout << "GPS time: " << _gps_ctrl->get_time() << std::endl; -- cgit v1.2.3 From 4d73aae4638e5c08b2f55ea229414319befec68e Mon Sep 17 00:00:00 2001 From: Nick Foster Date: Wed, 13 Apr 2011 12:32:35 -0700 Subject: GPS parser fixes for get_time. --- host/lib/usrp/gps_ctrl.cpp | 10 +++++----- host/lib/usrp/usrp2/mboard_impl.cpp | 2 -- 2 files changed, 5 insertions(+), 7 deletions(-) (limited to 'host/lib/usrp/usrp2/mboard_impl.cpp') diff --git a/host/lib/usrp/gps_ctrl.cpp b/host/lib/usrp/gps_ctrl.cpp index ace56e7ed..de97710f2 100644 --- a/host/lib/usrp/gps_ctrl.cpp +++ b/host/lib/usrp/gps_ctrl.cpp @@ -125,7 +125,6 @@ public: } -//TODO: this isn't generalizeable to non-USRP2 USRPs. std::string safe_gps_read() { return _recv(); } @@ -147,18 +146,19 @@ public: found_gprmc = true; break; } + boost::this_thread::sleep(boost::posix_time::milliseconds(200)); } UHD_ASSERT_THROW(found_gprmc); tok.assign(reply); toked.assign(tok.begin(), tok.end()); - UHD_ASSERT_THROW(toked.size() == 11); //if it's not we got something weird in there + UHD_ASSERT_THROW(toked.size() == 12); //if it's not we got something weird in there now = ptime( date( - greg_year(boost::lexical_cast(toked[8].substr(4, 2)) + 2000), //just trust me on this one - greg_month(boost::lexical_cast(toked[8].substr(2, 2))), - greg_day(boost::lexical_cast(toked[8].substr(0, 2))) + greg_year(boost::lexical_cast(toked[9].substr(4, 2)) + 2000), //just trust me on this one + greg_month(boost::lexical_cast(toked[9].substr(2, 2))), + greg_day(boost::lexical_cast(toked[9].substr(0, 2))) ), hours( boost::lexical_cast(toked[1].substr(0, 2))) + minutes(boost::lexical_cast(toked[1].substr(2, 2))) diff --git a/host/lib/usrp/usrp2/mboard_impl.cpp b/host/lib/usrp/usrp2/mboard_impl.cpp index 42ba714a4..62cc3c403 100644 --- a/host/lib/usrp/usrp2/mboard_impl.cpp +++ b/host/lib/usrp/usrp2/mboard_impl.cpp @@ -105,8 +105,6 @@ usrp2_mboard_impl::usrp2_mboard_impl( _iface->get_gps_write_fn(), _iface->get_gps_read_fn()); - //if(_gps_ctrl->gps_detected()) std::cout << "GPS time: " << _gps_ctrl->get_time() << std::endl; - //init the dsp stuff (before setting update packets) dsp_init(); -- cgit v1.2.3 From 6bd7281f83d5311675847b31746525841657c057 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Fri, 29 Apr 2011 11:02:08 -0700 Subject: usrp2: added support for GPSDO configuration bits in EEPROM Added instructions to install and burn eeprom to documentation. Made gps_ctrl and gps_time sensor optional. Added sensors for motherboard to documentation --- host/docs/usrp2.rst | 48 +++++++++++++++++++++++++++++++++++++ host/lib/usrp/mboard_eeprom.cpp | 23 ++++++++++++++++++ host/lib/usrp/usrp2/mboard_impl.cpp | 20 ++++++++++++---- 3 files changed, 86 insertions(+), 5 deletions(-) (limited to 'host/lib/usrp/usrp2/mboard_impl.cpp') diff --git a/host/docs/usrp2.rst b/host/docs/usrp2.rst index 161170f2c..2eb3ee796 100644 --- a/host/docs/usrp2.rst +++ b/host/docs/usrp2.rst @@ -345,3 +345,51 @@ Test the PPS input with the following app: cd /share/uhd/examples ./test_pps_input --args= + +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Internal GPSDO +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +USRP-N2XX models can have an optional internal GPSDO. +To use the GPSDO with UHD, you must burn an EEPROM setting +so that UHD knows that the internal GPSDO was installed. + +**Installation instructions:** + +1. Remove the daughterboard. +2. Move J510 jumper on the motherboard from 1-2 to 2-3 in order to switch from external 10 MHz Ref Clock to GPSDO’s 10 MHz Ref Clock +3. Screw the GPSDO module in place with the screws provided. The screws are treated to avoid loosening with vibration. +4. Connect the GPSDO power cable to J509 on the motherboard, and then to connector D on the GPSDO module +5. Connect an SMB to SMA cable between connectors B and J506 (PPS2) +6. Connect an SMB to SMA cable between connectors C and J507 (CLK REF2) +7. Connect the serial cable between connectors A and J312 (RS232-3) on the motherboard. If J312 on your USRP isn’t a keyed connector, please ensure to connect pin1 (TX) of connector A to pin3 (RX) on J312. +8. Remove the washer and nut from the MMCX to SMA-Bulkhead cable. Connect it to connector E and then insert SMA-Bulkhead connector through the hole in the rear panel. Tighten nut to fasten in place. +9. Replace the daughterboard pushing all the cables underneath. + +Then run the following commands: +:: + + cd /share/uhd/utils + ./usrp_burn_mb_eeprom --args= --key=gpsdo --val=internal + +**Removal instructions:** + +Restore the jumper setting, disconnect the cables, and unscrew the GPSDO unit. +Then run the following commands: +:: + + cd /share/uhd/utils + ./usrp_burn_mb_eeprom --args= --key=gpsdo --val=none + +------------------------------------------------------------------------ +Miscellaneous +------------------------------------------------------------------------ + +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Available Sensors +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +The following sensors are available for the USRP2/N-Series motherboards; +they can be queried through the API. + +* mimo_locked - clock reference locked over the MIMO cable +* ref_locked - clock reference locked (internal/external) +* gps_time - GPS seconds (available when GPSDO installed) diff --git a/host/lib/usrp/mboard_eeprom.cpp b/host/lib/usrp/mboard_eeprom.cpp index c90f4a2db..869a38478 100644 --- a/host/lib/usrp/mboard_eeprom.cpp +++ b/host/lib/usrp/mboard_eeprom.cpp @@ -74,10 +74,17 @@ static const uhd::dict USRP_N100_OFFSETS = boost::a ("mac-addr", 0x02) ("ip-addr", 0x0C) //leave space here for other addresses (perhaps) + ("gpsdo", 0x17) ("serial", 0x18) ("name", 0x18 + SERIAL_LEN) ; +enum n200_gpsdo_type{ + N200_GPSDO_NONE = 0, + N200_GPSDO_INTERNAL = 1, + N200_GPSDO_ONBOARD = 2 +}; + static void load_n100(mboard_eeprom_t &mb_eeprom, i2c_iface &iface){ //extract the revision number byte_vector_t rev_lsb_msb = iface.read_eeprom(N100_EEPROM_ADDR, USRP_N100_OFFSETS["rev-lsb-msb"], 2); @@ -93,6 +100,14 @@ static void load_n100(mboard_eeprom_t &mb_eeprom, i2c_iface &iface){ byte_copy(iface.read_eeprom(N100_EEPROM_ADDR, USRP_N100_OFFSETS["ip-addr"], 4), ip_addr_bytes); mb_eeprom["ip-addr"] = boost::asio::ip::address_v4(ip_addr_bytes).to_string(); + //gpsdo capabilities + boost::uint8_t gpsdo_byte = iface.read_eeprom(N100_EEPROM_ADDR, USRP_N100_OFFSETS["gpsdo"], 1).at(0); + switch(n200_gpsdo_type(gpsdo_byte)){ + case N200_GPSDO_INTERNAL: mb_eeprom["gpsdo"] = "internal"; break; + case N200_GPSDO_ONBOARD: mb_eeprom["gpsdo"] = "onboard"; break; + default: mb_eeprom["gpsdo"] = "none"; + } + //extract the serial mb_eeprom["serial"] = bytes_to_string(iface.read_eeprom( N100_EEPROM_ADDR, USRP_N100_OFFSETS["serial"], SERIAL_LEN @@ -136,6 +151,14 @@ static void store_n100(const mboard_eeprom_t &mb_eeprom, i2c_iface &iface){ iface.write_eeprom(N100_EEPROM_ADDR, USRP_N100_OFFSETS["ip-addr"], ip_addr_bytes); } + //gpsdo capabilities + if (mb_eeprom.has_key("gpsdo")){ + boost::uint8_t gpsdo_byte = N200_GPSDO_NONE; + if (mb_eeprom["gpsdo"] == "internal") gpsdo_byte = N200_GPSDO_INTERNAL; + if (mb_eeprom["gpsdo"] == "onboard") gpsdo_byte = N200_GPSDO_ONBOARD; + iface.write_eeprom(N100_EEPROM_ADDR, USRP_N100_OFFSETS["gpsdo"], byte_vector_t(1, gpsdo_byte)); + } + //store the serial if (mb_eeprom.has_key("serial")) iface.write_eeprom( N100_EEPROM_ADDR, USRP_N100_OFFSETS["serial"], diff --git a/host/lib/usrp/usrp2/mboard_impl.cpp b/host/lib/usrp/usrp2/mboard_impl.cpp index 62cc3c403..ae098dba6 100644 --- a/host/lib/usrp/usrp2/mboard_impl.cpp +++ b/host/lib/usrp/usrp2/mboard_impl.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -101,9 +102,11 @@ usrp2_mboard_impl::usrp2_mboard_impl( //contruct the interfaces to mboard perifs _clock_ctrl = usrp2_clock_ctrl::make(_iface); _codec_ctrl = usrp2_codec_ctrl::make(_iface); - _gps_ctrl = gps_ctrl::make( - _iface->get_gps_write_fn(), - _iface->get_gps_read_fn()); + if (_iface->mb_eeprom["gpsdo"] == "internal"){ + _gps_ctrl = gps_ctrl::make( + _iface->get_gps_write_fn(), + _iface->get_gps_read_fn()); + } //init the dsp stuff (before setting update packets) dsp_init(); @@ -361,7 +364,14 @@ void usrp2_mboard_impl::get(const wax::obj &key_, wax::obj &val){ case MBOARD_PROP_CLOCK_RATE: val = this->get_master_clock_freq(); return; - + + case SUBDEV_PROP_SENSOR_NAMES:{ + prop_names_t names = boost::assign::list_of("mimo_locked")("ref_locked"); + if (_gps_ctrl.get()) names.push_back("gps_time"); + val = names; + } + return; + case MBOARD_PROP_SENSOR: if(key.name == "mimo_locked") { val = sensor_value_t("MIMO", this->get_mimo_locked(), "locked", "unlocked"); @@ -371,7 +381,7 @@ void usrp2_mboard_impl::get(const wax::obj &key_, wax::obj &val){ val = sensor_value_t("Ref", this->get_ref_locked(), "locked", "unlocked"); return; } - else if(key.name == "gps_time") { + else if(key.name == "gps_time" and _gps_ctrl.get()) { val = sensor_value_t("GPS time", int(_gps_ctrl->get_epoch_time()), "seconds"); } else { -- cgit v1.2.3